value::try_as_uint64

Return result with a reference to the underlying std::uint64_t

Synopsis

boost::system::result< std::uint64_t & >
try_as_uint64() noexcept; (1)

boost::system::result< std::uint64_t >
try_as_uint64() const noexcept; (2)

Description

If is_uint64() is true, the result contains a reference to the underlying std::uint64_t, otherwise it contains an error_code.

Example

The return value can be used in both a boolean context and to assign a variable:

if( auto r = jv.try_as_uint64() )
    return *r;

But can also be used to throw an exception on error:

return jv.try_as_uint64().value();

Complexity

Constant.

Exception Safety

No-throw guarantee.