value::if_object

Return an object pointer if this is an object, else return nullptr

Synopsis

object const*
if_object() const noexcept; (1)

object*
if_object() noexcept; (2)

Description

If this->kind() == kind::object, returns a pointer to the underlying object. Otherwise, returns nullptr.

Example

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

if( auto p = jv.if_object() )
    return *p;

Complexity

Constant.

Exception Safety

No-throw guarantee.