Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Avoid Copy when adding a Tuple to a VectorMap
Avoid Copy when adding a Tuple to a VectorMap [message #57183] Sun, 06 June 2021 03:39 Go to previous message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Hello,

I'm working with a VectorMap<int, Tuple<int, A>>
class A don't provid a copy constructor, only a Move constructor.
I would like to add a new Tuple to my vector map by moving a fresh class A.
But I don't succeed... Can someone help me ? (I would like to avoid creation of a class to replace tuple in this specific case)
#include <Core/Core.h>

using namespace Upp;

class A{
	public:
		A(int e) : d_e(e){}
		A(A&& a){d_e = a.d_e;}
		int d_e;
};

CONSOLE_APP_MAIN
{
	VectorMap<int, Tuple<int, A>> myVector;
	myVector(1, pick(Tuple<int,A>(1, 5)));
	Cout() << myVector.Get(1).b.d_e << EOL;
	//Error : call to implicitly deleted copy constructor of 'A'
}

Also, why there is no Create(Args...) function in VectorMap ? (like the one in ArrayMap)

[Updated on: Sun, 06 June 2021 04:04]

Report message to a moderator

 
Read Message
Read Message
Read Message
Previous Topic: skylark
Next Topic: How to migrate my old packages to new version U++ in linux
Goto Forum:
  


Current Time: Sun Apr 27 09:56:08 CEST 2025

Total time taken to generate the page: 0.02977 seconds