...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Return the stored number as boost::system::result<T>
.
template<
class T>
boost::system::result
< T >
try_to_number() const noexcept;
This function attempts to return the stored value converted to the arithmetic
type T
which may not be
bool
:
T
is an integral
type and the stored value is a number which can be losslessly converted,
the conversion is performed without error and result<T>
containing the converted number
is returned.
T
is an integral
type and the stored value is a number which cannot be losslessly converted,
then result<T>
containing the corresponding error_code
is returned.
T
is a floating
point type and the stored value is a number, the conversion is performed
without error. result<T>
containing the converted number,
with a possible loss of precision, is returned.
this->is_number()
returns false
, then result<T>
containing the corresponding error_code
is returned.
std::is_arithmetic< T >::value && ! std::is_same< T, bool >::value
Constant.
No-throw guarantee.
boost::system::result<T>
with either the converted number or an error_code
.