Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-05-27 17:36:35

> ----- Mensaje original -----
> De: Peter Dimov <pdimov_at_[hidden]>
> Fecha: Viernes, Mayo 27, 2005 11:10 pm
> Asunto: Re: [boost] Re: compressed_pair requirements?
>>> IMHO, std::pair default ctor should be defined as
>>> pair():first(),second(){}
>> This doesn't change things. pair() {} is what you probably want.
> Why? (This is not a rethoric question, my understanding
> of value-initialization matters is so poor.)

Never mind, I probably didn't understand your intent. The above does indeed
eliminate the problem with the iterator while still leaving PODs
zero-initialized. pair() {} will leave PODs uninitialized.

> I think there's some value in having iterators being
> DefaultConstructible. Otherwise you're forced to have
> some container around everytime you construct an iterator.

I think that this is not that restrictive as it sounds, because an iterator
logically belongs to a container; it has no value on its own. A single
containerless iterator can be replaced by a pointer. An iterator range is,
of course, useful on its own, but you can't create a containerless range,
even an empty one, because...

> Defaut construction for iterators is roughly
> the equivalent of initializing to 0 in the case of pointers.

... default-constructed iterators are useless. A NULL pointer is copyable
and you can compare a NULL to another pointer, with well-defined results (so
you can make an empty range from two NULL pointers).

Default construction for iterators is a trap. :-)

Boost list run by bdawes at, gregod at, cpdaniel at, john at