2013/12/13 Andrey Semashev
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
(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