From: Ed Brey (brey_at_[hidden])
Date: 2000-06-28 12:17:38
From: "Kevlin Henney" <kevlin_at_[hidden]>
> (3) On a point of implementation rather than interface, I was wondering
> about reducing the cost of stringstream creation in single-threaded
> static std::stringstream stream;
This is OK only if we make a rule saying that iostream overload
implementations for user-defined types can't use stream_cast. For example,
say you have a Point class and an Area class, each of which store two
integers and read and write them to streams of the form "123,456", but are
otherwise unrelated. They could be converted with stream_cast. If either
of them, for whatever reason, would happen to use stream_cast in their
streaming implementations, you'd run into a reentrancy problem.
On a separate sub-thread, Jeffrey Paquette wrote:
> Why not go with existing practice and write:
> a = interpret_cast<A>(b, std::nothrow);
> for the non-throwing version?
The nothrow version has been suggested before (several times, I think). A
problem is that there is no way to know whether the conversion succeeded or
failed. Unlike with a pointer to a new memory allocation, there is no
special value for a converted type to indicate that the conversion failed.
The form of the conversion/cast that returns a bool addresses this problem.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk