tt::is_maplike< T, typename > Struct Template Reference

Check if type T is like a std::map or std::unordored_map. More...

#include <IsMaplike.hpp>

Detailed Description

template<typename T, typename = std::void_t<>>
struct tt::is_maplike< T, typename >

Check if type T is like a std::map or std::unordored_map.

Details

Inherits from std::true_type if the type T has a type alias key_type, type alias mapped_type, and operator[](const typename T::key_type&) defined, otherwise inherits from std::false_type

Usage

For any type T,

using result = tt::is_maplike<T>;

Returns: std::bool_constant

Semantics: If the type T has a type alias key_type, type alias mapped_type, and operator[](const typename T::key_type&) defined, then

typename result::type = std::true_type;

otherwise

typename result::type = std::false_type;

Example

"Failed testing type trait is_maplike");
"Failed testing type trait is_maplike");
"Failed testing type trait is_maplike");
static_assert(tt::is_maplike<std::map<int, C>>::value,
"Failed testing type trait is_maplike");
static_assert(not tt::is_maplike<std::vector<C>>::value,
"Failed testing type trait is_maplike");
static_assert(not tt::is_maplike<D>::value,
"Failed testing type trait is_maplike");
See also
std::map std::unordered_map is_a
Template Parameters
Tthe type to check

The documentation for this struct was generated from the following file:
std::true_type
std::vector
tt::is_maplike
Check if type T is like a std::map or std::unordored_map.
Definition: IsMaplike.hpp:47
std::map
tt::is_maplike_v
constexpr bool is_maplike_v
Definition: IsMaplike.hpp:60
tt::is_maplike_t
typename is_maplike< T >::type is_maplike_t
Definition: IsMaplike.hpp:64
std::unordered_map