## `value::try_as_object`

Return `result` with a reference to the underlying `object`.

### Synopsis

    boost::system::result< object & >
    try_as_object() noexcept; (1)

    boost::system::result< object const & >
    try_as_object() const noexcept; (2)

### Description

If `is_object()` is `true`, the result contains a reference to the underlying `object`, 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_object() )
        return *r;

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

    return jv.try_as_object().value();

### Complexity

Constant.

### Exception Safety

No-throw guarantee.

Edit this page