Re: Inserting objects into a std::map?
On Mar 27, 10:05 pm, red floyd <no.s...@here.dude> wrote:
saneman wrote:
Another thing. When I make:
std::map<Bob, int> m;
And my Bob class does not define '<' operator why does the
compiler not complain in the above declaration of 'm'?
It's called SFNIAE (Substitution Failure Is Not An Error).
No it's not. It's called undefined behavior. SFNIAE is
something else entirely (and only concerns function templates,
since it takes place in template argument deduction).
Until the problematic code is instantiated (by the insert call
below), there isn't a problem.
Just because the compiler doesn't complain doesn't mean that
there's no problem, or that the code is correct. Undefined
behavior is undefined behavior, and unless your implementation
explicitly defines it, it is an error.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34