From: Kevlin Henney (kevlin_at_[hidden])
Date: 2000-06-01 16:26:52
In message <02a801bfca4d$9d434fb0$3e116e97_at_[hidden]>, Ed Brey
>For the unchecked version, Dave Abrahams had suggested stream_cast
>with a std::nothrow_t parameter. The decision on what to call the
>unchecked version probably should be based on its semantics.
>In summary, it might be that the non-throwing version is used so
>rarely that it's not worth having. If it is useful, the next question
>is how common is it that the default initialized target is desired if
>there is an error? If the answer isn't "almost always", the target
>should be passed in by reference. Then finally, what should it be
>called? Unchecked is somewhat misleading, since there is a check
>preventing target from containing just garbage if there is a failure.
>Instead something term that differentiates what happens if the check
>fails seems more appropriate, although I don't have a suggestion for
Just realised that I haven't responded to this thread. Unfortunately I'm
a bit short of time at the moment, and out of email contact as of
tomorrow for the next week, otherwise I would give a longer, more
detailed answer. Anyway, the highlights:
* I have the default initialisation to be useful and a sensible default,
following the script soft-failure, "do something sensible" model, hence
why the original version did this.
* An exception throwing variant is also useful.
* Other variants wrt how conversions are done are also useful, ie
different interpretation methods (not necessarily stream-based).
* A trait based technique can be used that accommodates this variability
whilst maintaining a single cast function.
I will pick up any discussion and comments next week, produce a version
of the code and, importantly, worked examples for further feedback.
Kevlin Henney phone: +44 117 942 2990
Curbralan Ltd mobile: +44 7801 073 508
kevlin_at_[hidden] fax: +44 870 052 2289
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk