Date: 2000-01-03 08:58:15
> A while ago Kevlin Henney sent me a clever idea for a stream_cast
> template which supports conversions to and from heterogeneous types
> via a stream.
> I asked him for some documentation and a sample program, which he has
> now provided. They are posted in the eGroups vault at
> Kevlin writes, "It is currently in experimental phase, and I would
> very much appreciate your initial thoughts on it."
I think this is a great idea! I don't know about anyone else, but I could
certainly use it!
I recommend we add it to boost. There is only one change I would like -- it
would be nice in some cases to have stream_cast throw an exception instead
of returning T(). Taking an example from the documentation, stream_cast is
used to translate the command-line parameters to shorts; but if one of them
is not translatable, short() is returned, which holds an unspecified yet
valid value. If an exception was thrown instead, we would be able to know
if the parameters were all valid shorts or not. Maybe we could add another
function - stream_cast_throw?
Another possible addition: (not just for stream_cast but all other kinds of
casts): stream_cast_t<Target, Source> which is a unary function object. Has
this been discussed yet?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk