forked from boostorg/conversion
Do not treat critcal errors as bad_lexical_cast exceptions, but if exceptions are on throw correct exception instead (refs #8966)
[SVN r85232]
This commit is contained in:
@@ -1616,6 +1616,11 @@ namespace boost {
|
|||||||
// does not support such conversions. Try updating it.
|
// does not support such conversions. Try updating it.
|
||||||
BOOST_STATIC_ASSERT((boost::is_same<char, CharT>::value));
|
BOOST_STATIC_ASSERT((boost::is_same<char, CharT>::value));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
|
out_stream.exceptions(std::ios::badbit);
|
||||||
|
try {
|
||||||
|
#endif
|
||||||
bool const result = !(out_stream << input).fail();
|
bool const result = !(out_stream << input).fail();
|
||||||
const buffer_t* const p = static_cast<buffer_t*>(
|
const buffer_t* const p = static_cast<buffer_t*>(
|
||||||
static_cast<std::basic_streambuf<CharT, Traits>*>(out_stream.rdbuf())
|
static_cast<std::basic_streambuf<CharT, Traits>*>(out_stream.rdbuf())
|
||||||
@@ -1623,6 +1628,11 @@ namespace boost {
|
|||||||
start = p->pbase();
|
start = p->pbase();
|
||||||
finish = p->pptr();
|
finish = p->pptr();
|
||||||
return result;
|
return result;
|
||||||
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
|
} catch (const ::std::ios_base::failure& /*f*/) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
@@ -1996,6 +2006,10 @@ namespace boost {
|
|||||||
#endif // BOOST_NO_STD_LOCALE
|
#endif // BOOST_NO_STD_LOCALE
|
||||||
#endif // BOOST_NO_STRINGSTREAM
|
#endif // BOOST_NO_STRINGSTREAM
|
||||||
|
|
||||||
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
|
stream.exceptions(std::ios::badbit);
|
||||||
|
try {
|
||||||
|
#endif
|
||||||
stream.unsetf(std::ios::skipws);
|
stream.unsetf(std::ios::skipws);
|
||||||
lcast_set_precision(stream, static_cast<InputStreamable*>(0));
|
lcast_set_precision(stream, static_cast<InputStreamable*>(0));
|
||||||
|
|
||||||
@@ -2010,6 +2024,12 @@ namespace boost {
|
|||||||
#else
|
#else
|
||||||
Traits::eof();
|
Traits::eof();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
|
} catch (const ::std::ios_base::failure& /*f*/) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@@ -222,7 +222,8 @@ static void testing_template_array_output_on_char_value()
|
|||||||
BOOST_CHECK(&res3[0] == u16ethalon);
|
BOOST_CHECK(&res3[0] == u16ethalon);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CHECK_THROW(lexical_cast<u16short_arr_type>(val), boost::bad_lexical_cast);
|
// Some compillers may throw std::bad_alloc here
|
||||||
|
BOOST_CHECK_THROW(lexical_cast<u16short_arr_type>(val), std::exception);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BOOST_LC_RUNU32
|
#ifdef BOOST_LC_RUNU32
|
||||||
@@ -248,7 +249,8 @@ static void testing_template_array_output_on_char_value()
|
|||||||
BOOST_CHECK(&res3[0] == u32ethalon);
|
BOOST_CHECK(&res3[0] == u32ethalon);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CHECK_THROW(lexical_cast<u32short_arr_type>(val), boost::bad_lexical_cast);
|
// Some compillers may throw std::bad_alloc here
|
||||||
|
BOOST_CHECK_THROW(lexical_cast<u32short_arr_type>(val), std::exception);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user