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 » U++ Library support » U++ Core » Understanding pick behaviour and containers
Understanding pick behaviour and containers [message #15627] Thu, 01 May 2008 21:09 Go to previous message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Let`s say, one needs to have hashed container of some complex objects. OK, taking Index and putting some moveable and optional deep copy flavour to objects contained:

class AAA : public VectorMap<int, int>, public MoveableAndDeepCopyOption<AAA>
{
public:
	AAA() {}
	AAA(const AAA &, int) {}
	unsigned GetHashValue() const {return 0;/*proxy here*/;}
};

CONSOLE_APP_MAIN
{
	AAA a;
	a.Add(10,1);
	AAA a2(a);
	Cout() << a2.GetCount();
	
	Index<AAA> ai;
	ai.Add(a2);
	Cout() << " / " << ai[0].GetCount();
}


Output gives us 1 / 0. First value is OK, since first pick operation succeeded. Second one is zero, which is not right IMO: I added object to Index and it didn`t appear in the container.
When we talk about Vector or even VectorMap - it`s OK, we have AddPick() there, which works in this case.

So, why add operation didn`t work and how to solve this?

P.S. Why (pick_ != const) for MSC compiler?

[Updated on: Thu, 01 May 2008 21:12]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Convenient work with options/properties
Next Topic: cout, cin etc. question
Goto Forum:
  


Current Time: Mon Apr 29 19:49:38 CEST 2024

Total time taken to generate the page: 0.01829 seconds