|
Boost : |
Subject: Re: [boost] [lexical_cast] A non-throwing lexical cast? [Was: 5 Observations - My experience with the boost libraries]
From: Tom Brinkman (reportbase2007_at_[hidden])
Date: 2010-03-25 15:32:27
or
boost::lexical_cast_no_throw()
On Thu, Mar 25, 2010 at 11:57 AM, Kim Barrett
<kab.conundrums_at_[hidden]> wrote:
>
> On Mar 25, 2010, at 2:17 PM, Bruno Santos wrote:
>>>>>> boost::lexical_cast - throws. Almost always needs to be caught
>>>>>> and re-thrown.
>>>>> Why? Is it because you need to do some cleanup? Do you known what
>>>>> RAII is?
>>>>
>>>> Exception translation, i.e. "re-thrown" as in "thrown in a different
>>>> form". boost::bad_lexical_cast is not derived from
>>>> my_project::invalid_user_input o or whatever. This happens a lot with
>>>> boost::lexical_cast.
>>>
>>
>> What about boost::system::error_code as the second parameter for the non
>> throwing version? And it does not suffer from the return error code
>> problem. Just take a look at boost::filesystem and boost::asio.
>
> The point was that the present interface for boost::lexical_cast often leads to try/catch blocks.
>
> I like this suggestion of a second error_code argument a lot.
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk