|
|
associative containers: requirements
Hello,
I would like to know what the exact requirements are for classes that use
associative containers in terms of which overloaded operators and
constructors they must provide. For instance, if I have a class
called Foo, and declare and std::map<Foo>, then what other
methods and constructors must Foo implement for
std::map<Foo> to work as expected besides
bool operator<(const Foo &foo) const;
Thanks,
Neil
|
|
0
|
|
|
|
Reply
|
nzanella (147)
|
10/17/2003 1:51:34 AM |
|
"Neil Zanella" <nzanella@cs.mun.ca> wrote...
> I would like to know what the exact requirements are for classes that use
> associative containers in terms of which overloaded operators and
> constructors they must provide. For instance, if I have a class
> called Foo, and declare and std::map<Foo>, then what other
> methods and constructors must Foo implement for
> std::map<Foo> to work as expected besides
>
> bool operator<(const Foo &foo) const;
Actually, that is not even a requirement. You may supply your own
comparator for the keys. The requirement for the comparator 'comp',
though, is that in order for two keys 'k1' and 'k2' to be _equivalent_,
comp(k1,k2) should be false _as_well_as_ comp(k2,k1).
BTW, you cannot declare std::map<Foo> because std::map needs at least
two template arguments.
Get yourself a copy of Nicolai Josuttis' "The C++ Standard Library".
It will be the best book you've used. Trust me.
Victor
|
|
0
|
|
|
|
Reply
|
v.Abazarov1 (626)
|
10/17/2003 4:48:13 AM
|
|
|
1 Replies
39 Views
(page loaded in 0.06 seconds)
Similiar Articles: improve strlen - comp.lang.asm.x86... things like sets, lists, maps, or other containers that people do so without thinking about the costs associated ... strlen over and over again because the requirements ... [comp.publish.cdrom] CD-Recordable FAQ, Part 1/4 - comp.publish ...Archive-name: cdrom/cd-recordable/part1 Posting-Frequency: monthly Last-modified: 2008/10/09 Version: 2.71 Send corrections and updates to And... top 10 uses for random data compression?? anyone? - comp ...Lots of containers eg devise the radical rock. Some potatos promise, accumulate ... Otherwise the prospect in Tommy's shower might integrate some associated visions. SolidWorks Sucks... - comp.cad.solidworks... dummy" sub-assy (i.e. ones that are just containers to ... but they are definitely no measure for the requirements of ... containing weldments, machined parts and the associated ... Associative Container - SGI - The Trusted Leader in Technical ...An Associative Container is a variable-sized Container that supports efficient ... is introduced, in addition to the types defined in the Forward Container requirements. Simple Associative Container - SGI - The Trusted Leader in ...None, except for those described in the Associative Container requirements. Simple Associative Container, however, introduces two new type restrictions. 7/13/2012 9:23:55 AM
|
|
|
|
|
|
|
|
|