value::as_double

Return the underlying double, or throw an exception.

Synopsis

double&
as_double(
    boost::source_location const& loc = BOOST_CURRENT_LOCATION); (1)

double
as_double(
    boost::source_location const& loc = BOOST_CURRENT_LOCATION) const; (2)

Description

If is_double() is true, returns a reference to (1) or a copy of (2) the underlying double, otherwise throws an exception.

This function is intended for direct access to the underlying object, if it has the type double. It does not convert the underlying object to type double even if a lossless conversion is possible. If you are not sure which kind your value has, and you only care about getting a double number, consider using to_number instead.

Exception Safety

Strong guarantee.

Parameters

Name Description

loc

boost::source_location to use in thrown exception; the source location of the call site by default.

Exceptions

Type Thrown On

boost::system::system_error

! this->is_double().

Complexity

Constant.