|
Boost Users : |
From: Scott Meyers (usenet_at_[hidden])
Date: 2006-09-14 01:28:12
Marshall Clow wrote:
> At 9:06 PM -0700 9/13/06, Scott Meyers wrote:
> [ snip ]
>> 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;
>> std::string s;
>
> Just a nit - I think that your third example is not like the others.
> A std::string, AFAIK, constructed with the default constructor, is
> perfectly valid - just empty.
In each case, a default constructor is invoked. They're all valid
objects that presumably fulfill their invariants, it's just that you
can't safely invoke very many operations on them. On the string s, for
example, invoking size is fine, but invoking operator[] is not fine at all.
Scott
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