Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2006-09-14 07:04:35


Scott Meyers <usenet_at_[hidden]> writes:

> I'll note that C++ itself allows "uninitialized" objects with
> constructors to be created all the time:

That doesn't make it a good practice and general, and...

> std::ofstream ofs;
> std::vector<int>::iterator i;

...these two are examples (although at least the documentation about what
that means is rigorous and complete)

> std::string s;

...but this is not an example of it

> In each case, there are a few operations that can legitimately be
> performed on such objects, but many operations lead to UB. Is this
> fundamentally different from the EventLog example? For example, replace
> EventLog in my example with ofstream, and you have
>
> std::ofstream ofs;
> ofs << "Hello World";
>
> Trouble ensues, just as it did in the EventLog example.

Yeah, nobody these days claims that the iostreams are an example of
stellar, state-of-the-art C++ library design.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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