folly::get_ptr

get_ptr overloads

Synopses

Declared in <folly/container/MapUtil.h>

Non-const overload of the above.

template<
    class Map,
    typename Key = Map::key_type>
auto
get_ptr(
    Map& map,
    Key const& key);
» more...

Given a map and a key, return a pointer to the corresponding value, or nullptr if the key doesn't exist in the map.

template<
    class Map,
    typename Key = Map::key_type>
auto
get_ptr(
    Map const& map,
    Key const& key);
» more...

Given a map and a key, return a pointer to the value corresponding to the key in the map, or nullptr if the key doesn't exist in the map.

template<
    class Map,
    typename Key = Map::key_type>
auto
get_ptr(
    Map&& map,
    Key const& key)
requires (!std::is_lvalue_reference_v<Map>) = delete;
» more...

Given a map pointer and a key, return a pointer to the corresponding value, or nullptr if the map is null or the key doesn't exist.

template<
    class Map,
    typename Key = Map::key_type>
Map::mapped_type*
get_ptr(
    Map* map,
    Key const& key);
» more...

Given a map pointer and a key, return a pointer to the corresponding value, or nullptr if the map is null or the key doesn't exist.

template<
    class Map,
    typename Key = Map::key_type>
Map::mapped_type const*
get_ptr(
    Map const* map,
    Key const& key);
» more...

Given a map of maps and a path of keys, return a pointer to the nested value, or nullptr if the key doesn't exist in the map.

template<
    class Map,
    class Key1,
    class Key2,
    class... Keys>
/* implementation-defined */::type*
get_ptr(
    Map& map,
    Key1 const& key1,
    Key2 const& key2,
    Keys const&... keys);
» more...

Given a map of maps and a path of keys, return a pointer to the nested value, or nullptr if the key doesn't exist in the map.

template<
    class Map,
    class Key1,
    class Key2,
    class... Keys>
/* implementation-defined */::type const*
get_ptr(
    Map const& map,
    Key1 const& key1,
    Key2 const& key2,
    Keys const&... keys);
» more...

Given a map of maps and a path of keys, return a pointer to the nested value, or nullptr if the key doesn't exist in the map.

template<
    class Map,
    class Key1,
    class Key2,
    class... Keys>
auto
get_ptr(
    Map&& map,
    Key1 const& key1,
    Key2 const& key2,
    Keys const&... keys)
requires (!std::is_lvalue_reference_v<Map>) = delete;
» more...

Given a map of maps and a path of keys, return a pointer to the nested value, or nullptr if the key doesn't exist in the map.

template<
    class Map,
    class Key1,
    class Key2,
    class... Keys>
/* implementation-defined */::type*
get_ptr(
    Map* map,
    Key1 const& key1,
    Key2 const& key2,
    Keys const&... keys);
» more...

Given a map of maps and a path of keys, return a pointer to the nested value, or nullptr if the key doesn't exist in the map.

template<
    class Map,
    class Key1,
    class Key2,
    class... Keys>
/* implementation-defined */::type const*
get_ptr(
    Map const* map,
    Key1 const& key1,
    Key2 const& key2,
    Keys const&... keys);
» more...

Return Value

  • A pointer to the value, or nullptr if the key doesn't exist.
  • A pointer to the value, or nullptr if the map is null or absent.
  • A pointer to the nested value, or nullptr if the path is absent.

Parameters

NameDescription
mapThe map to search.
keyThe key to look up.
key1The first key in the path.
key2The second key in the path.
keysThe remaining keys in the path.