13 #ifndef TINYMPL_VALUE_MAP_HPP
14 #define TINYMPL_VALUE_MAP_HPP
16 #include <tinympl/algorithm.hpp>
17 #include <tinympl/map.hpp>
33 template<
class KeyType,
class ValueType,
class ... Args>
40 template<KeyType k>
struct is_valid_key_type<std::integral_constant<KeyType,k>> : std::true_type {};
46 template<ValueType k>
struct is_valid_value_type<std::integral_constant<ValueType,k>> : std::true_type {};
56 template<KeyType k>
using key = std::integral_constant<KeyType,k>;
61 template<ValueType v>
using value = std::integral_constant<ValueType,v>;
66 template<KeyType k,ValueType v>
78 static_assert(index <
sizeof...(Args),
"Key k not present in the map");
80 typedef typename variadic::at<index,Args...>::type::second_type type;
81 enum {
value = type::value};
99 using count = std::integral_constant<
107 template<KeyType k,ValueType v>
110 typedef typename std::conditional<
113 value_map<KeyType,ValueType,Args...> >::type type;
120 template<
class ... KeyValuePairs>
139 template<
class T>
struct key_comparer : std::is_same<typename T::first_type,key<k> > {};
141 template<
class ... Ts>
149 template<
class KeyType,
class ValueType,
class ... As,
class ... Bs>
154 #endif // TINYMPL_VALUE_MAP_HPP
std::integral_constant< std::size_t,(variadic::find< key< k >, typename Args::first_type... >::type::value==size?0:1)> count
Count the number of elements in the map with a given key.
Definition: value_map.hpp:101
Determines whether every element in the sequence satisfies the given predicate.
Definition: all_of.hpp:31
Extract the i-th element of a variadic template.
Definition: at.hpp:27
Determines whether it is possible to reorder the sequence A to match exactly the sequence B ...
Definition: unordered_equal.hpp:40
Remove the elements from the input sequence if they satisfy a given predicate.
Definition: remove_if.hpp:39
Calls insert many times to insert many Key/Value pairs.
Definition: value_map.hpp:121
Determines whether the map is empty.
Definition: value_map.hpp:91
Collapses a sequence starting from left using a functor.
Definition: left_fold.hpp:28
Determines whether the types A and B are equal.
Definition: equal_to.hpp:27
Get the number of elements of a sequence.
Definition: size.hpp:27
Compute the index of the first element in the sequence which is equal to the given type T...
Definition: find.hpp:38
A compile time map from a compile-time value to another This class represents a compile time mapping ...
Definition: value_map.hpp:34
Determines whether T is a valid value type, i.e. std::integral_constant
Definition: value_map.hpp:45
std::integral_constant< ValueType, v > value
Convenience using-declaration to quickly define values for this value_map
Definition: value_map.hpp:61
Return a new map constructed by the current map removing the k key, if present, otherwise return the ...
Definition: value_map.hpp:137
std::integral_constant< KeyType, k > key
Convenience using-declaration to quickly define keys for this value_map
Definition: value_map.hpp:56
Return the value element with the given key.
Definition: value_map.hpp:74
Returns a new map with the new Key/Value pair, or this map if the key is already present in the map...
Definition: value_map.hpp:108
Determines whether T is a valid key type, i.e. std::integral_constant ...
Definition: value_map.hpp:39
Determines whether the input sequence contains only unique elements.
Definition: is_unique.hpp:35
std::pair< key< k >, value< v > > pair
Convenience using-declaration to quickly define a key/value pair for this value_map ...
Definition: value_map.hpp:67