Subject: Re: [Boost-bugs] [Boost C++ Libraries] #7063: try_unhex() that doesn't throw on bad input
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-09-24 16:59:47
#7063: try_unhex() that doesn't throw on bad input
-------------------------------------------------------+--------------------
Reporter: Olaf van der Spek <olafvdspek@â¦> | Owner: marshall
Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: algorithm
Version: Boost 1.51.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------------------------------+--------------------
Comment (by marshall):
Something like this?
Of course, it will still throw if a memory allocation fails. Or the output
iterator throws. Or the input iterator throws. Or one of the assignments
throw.
{{{
template <typename InputIter, typename OutputIter>
bool try_unhex ( InputIter first, InputIter last, OutputIter out ) {
try {
(void) unhex ( first, last, out );
return true;
}
catch ( const hex_decode_error & ) {}
return false;
}
}}}
Note:
* if you pass the output iterator by value, then you lose any changes that
are made.
* If you pass the output iterator by reference, then you can't use an
unnamed temporary (such as the result of `std::back_inserter`)
In any case, I'm not convinced that this is a good idea.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/7063#comment:3> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC