Boost logo

Boost :

From: Mark Rodgers (mark.rodgers_at_[hidden])
Date: 2000-06-06 14:40:21


From: Don Waugaman <dpw_at_[hidden]>
>
> Could we accomodate both approaches from the same interface? I'm
> thinking here of having a stream_cast(std::nothrow) option, somewhat
> like how the new operator works.
>
> template<typename Target, typename Source>
> inline Target stream_cast(Source arg, std::nothrow_t &)
>
> This would allow use of the throwing stream_cast without qualification,
> and allow the programmer to select the non-throwing stream_cast when
> appropriate. It uses a familiar mechanism to differentiate between
> the two alternatives.
>
> Thoughts?

I'm sorry, I don't appear to have made myself clear. I was indeed
intending to support both options, but was suggesting the default
argument be the differentiator, rather than a "useless" nothrow_t.

template<typename Target, typename Source>
Target stream_cast(const Source &arg)
    // throws exception on error

template<typename Target, typename Source>
Target stream_cast(const Source &arg, const Target &def)
    // returns def on error

Mark


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk