#pragma once
#include <tuple>
#include <folly/Conv.h>
#include <folly/Optional.h>
#include <folly/Range.h>
#include <folly/functional/Invoke.h>
namespace folly {
template <typename Map, typename Key>
typename Map::mapped_type get_default(const Map& map, const Key& key) { … }
template <
class Map,
typename Key = typename Map::key_type,
typename Value = typename Map::mapped_type,
typename std::enable_if<!is_invocable_v<Value>>::type* = nullptr>
typename Map::mapped_type get_default(
const Map& map, const Key& key, Value&& dflt) { … }
template <
class Map,
typename Key = typename Map::key_type,
typename Func,
typename = typename std::enable_if<
is_invocable_r_v<typename Map::mapped_type, Func>>::type>
typename Map::mapped_type get_default(
const Map& map, const Key& key, Func&& dflt) { … }
template <
class E = std::out_of_range,
class Map,
typename Key = typename Map::key_type>
const typename Map::mapped_type& get_or_throw(
const Map& map,
const Key& key,
const StringPiece& exceptionStrPrefix = StringPiece()) { … }
template <
class E = std::out_of_range,
class Map,
typename Key = typename Map::key_type>
typename Map::mapped_type& get_or_throw(
Map& map,
const Key& key,
const StringPiece& exceptionStrPrefix = StringPiece()) { … }
template <
template <typename> class Optional = folly::Optional,
class Map,
typename Key = typename Map::key_type>
Optional<typename Map::mapped_type> get_optional(
const Map& map, const Key& key) { … }
template <class Map, typename Key = typename Map::key_type>
const typename Map::mapped_type& get_ref_default(
const Map& map, const Key& key, const typename Map::mapped_type& dflt) { … }
template <class Map, typename Key = typename Map::key_type>
const typename Map::mapped_type& get_ref_default(
const Map& map, const Key& key, typename Map::mapped_type&& dflt) = delete;
template <class Map, typename Key = typename Map::key_type>
const typename Map::mapped_type& get_ref_default(
const Map& map,
const Key& key,
const typename Map::mapped_type&& dflt) = delete;
template <
class Map,
typename Key = typename Map::key_type,
typename Func,
typename = typename std::enable_if<
is_invocable_r_v<const typename Map::mapped_type&, Func>>::type,
typename = typename std::enable_if<
std::is_reference<invoke_result_t<Func>>::value>::type>
const typename Map::mapped_type& get_ref_default(
const Map& map, const Key& key, Func&& dflt) { … }
template <class Map, typename Key = typename Map::key_type>
const auto* get_ptr(const Map& map, const Key& key) { … }
template <class Map, typename Key = typename Map::key_type>
auto* get_ptr(Map& map, const Key& key) { … }
template <class Map, typename Key = typename Map::key_type>
std::pair<const typename Map::mapped_type*, const typename Map::mapped_type*>
get_ptr2(const Map& map, const Key& key0, const Key& key1) { … }
template <class Map, typename Key = typename Map::key_type>
std::pair<typename Map::mapped_type*, typename Map::mapped_type*> get_ptr2(
Map& map, const Key& key0, const Key& key1) { … }
namespace detail {
template <
class T,
size_t pathLength,
class = typename std::enable_if<(pathLength > 0)>::type>
struct NestedMapType { … };
NestedMapType<T, 1>;
template <typename... KeysDefault>
struct DefaultType;
DefaultType<Default>;
DefaultType<Key, KeysDefault...>;
template <class... KeysDefault>
auto extract_default(const KeysDefault&... keysDefault) ->
typename DefaultType<KeysDefault...>::type const& { … }
}
template <class Map, class Key1, class Key2, class... Keys>
auto get_optional(
const Map& map, const Key1& key1, const Key2& key2, const Keys&... keys)
-> folly::Optional<
typename detail::NestedMapType<Map, 2 + sizeof...(Keys)>::type> { … }
template <class Map, class Key1, class Key2, class... Keys>
auto get_ptr(
const Map& map, const Key1& key1, const Key2& key2, const Keys&... keys) ->
typename detail::NestedMapType<Map, 2 + sizeof...(Keys)>::type const* { … }
template <class Map, class Key1, class Key2, class... Keys>
auto get_ptr(Map& map, const Key1& key1, const Key2& key2, const Keys&... keys)
-> typename detail::NestedMapType<Map, 2 + sizeof...(Keys)>::type* { … }
template <
class Map,
class Key1,
class Key2,
class... KeysDefault,
typename = typename std::enable_if<sizeof...(KeysDefault) != 0>::type>
auto get_default(
const Map& map,
const Key1& key1,
const Key2& key2,
const KeysDefault&... keysDefault) ->
typename detail::NestedMapType<Map, 1 + sizeof...(KeysDefault)>::type { … }
template <
class Map,
class Key1,
class Key2,
class... KeysDefault,
typename = typename std::enable_if<sizeof...(KeysDefault) != 0>::type,
typename = typename std::enable_if<std::is_lvalue_reference<
typename detail::DefaultType<KeysDefault...>::type>::value>::type>
auto get_ref_default(
const Map& map,
const Key1& key1,
const Key2& key2,
KeysDefault&&... keysDefault) ->
typename detail::NestedMapType<Map, 1 + sizeof...(KeysDefault)>::type
const& { … }
}