value::if_bool

## `value::if_bool`

Return a pointer to the underlying `bool` .

### Synopsis

    bool const*
    if_bool() const noexcept; (1)

    bool*
    if_bool() noexcept; (2)

### Description

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

### Example

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

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

### Complexity

Constant.

### Exception Safety

No-throw guarantee.

Edit this page