|
Boost : |
Subject: Re: [boost] [conversion] try_lexical_cast and 200$
From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2013-12-15 01:26:07
2013/12/13 Andrey Semashev <andrey.semashev_at_[hidden]>
> On Friday 13 December 2013 15:51:20 Antony Polukhin wrote:
> > Thank you all for giving comments and ideas!
> >
> > Looks like it'll be `bool try_lexical_convert<Out, In>(const In&, Out&)`:
> >
> > * boost::optional version adds additional dependency + boost::optional
> > does not support move semantics well, so it'll be hard to implement a
> very
> > efficient try_lexical_convert with current boost::optional
> > * returning bool looks like the simplest solution that can be easily
> > adopted by user
> > * output parameter is at the last position (like it is done in many
> > Standard Library methods)
> > * name contains "convert" instead of "cast", because function does not
> look
> > like a cast
>
> May I suggest that the first argument is an rvalue reference, and the
> function
> performs perfect forwarding to the operator<<? This is of course when
> rvalue
> references are available.
>
This may be useful for user defined types, but portably getting pointer to
function in that case will be difficult. For try_lexical_convert first
argument will be rvalue, but lexical_cast continue to accept parameters by
const reference.
-- Best regards, Antony Polukhin
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk