Boost logo

Boost Users :

From: David Walthall (walthall_at_[hidden])
Date: 2006-09-15 12:09:47


Scott Meyers wrote:
> I'll note that C++ itself allows "uninitialized" objects with
> constructors to be created all the time:
>
> std::ofstream ofs;
> std::vector<int>::iterator i;

The only time I have found it useful to have default-constructed objects
that are otherwise unusable is when I need to store them in a map or
other container that requires a default constructible object. That
allows me to use the easier operator[] syntax instead of using insert
and find. However, I've begun to view that as a defect in the interface
of std::map rather than a need to have default constructible objects
even when they are not usable.

David


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net