object::if_contains

## `object::if_contains`

Return a pointer to the value if the key is found, or null.

### Synopsis

    value const*
    if_contains(
        string_view key) const noexcept; (1)

    value*
    if_contains(
        string_view key) noexcept; (2)

### Description

This function searches for a value with the given key, and returns a pointer to it if found. Otherwise it returns null.

### Example

    if( auto p = obj.if_contains( "key" ) )
        std::cout << *p;

### Complexity

Constant on average, worst case linear in `size()`.

### Exception Safety

No-throw guarantee.

### Parameters

Name | Description
--- | ---
`key` | The key of the element to find.

### See Also

`find`.

Edit this page