
"Matthias Hofmann" <hofmann@anvil-soft.com> writes:
"David Abrahams" <dave@boost-consulting.com> schrieb im Newsbeitrag news:87bqphhxjl.fsf@pereiro.luannocracy.com...
David Walthall <walthall@stanfordalumni.org> writes:
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.
No standard containers have that requirement, though.
This seems to be another defect, as the standard also defines the following constructor:
explicit vector(size_type n, const T& value = T(), const Allocator& = Allocator());
Now how is the following code supposed to compile:
#include <vector>
struct X { X( int ) {} };
void f() { // Error: No default constructor for X. std::vector<X> v( 5 ); }
That's not a defect; it's simply _not_ supposed to compile! -- Dave Abrahams Boost Consulting www.boost-consulting.com