◆ as_map

#include <metal/map/map.hpp>

Description

Constructs a Map out of any Value that is a specialization of a template class or union whose template parameters are all themselves specializations of template classes or unions that take exactly two template parameters, the first Values of which are all distinct.

Usage

For any Value val

using result = metal::as_map<val>;
Returns
: Map

Example

template<class...> struct a {};
template<class...> struct b {};
template<class...> struct c {};
IS_SAME(
metal::as_map<a<b<int, int*>, c<char, char*>>>,
);
IS_SAME(
metal::as_map<std::tuple<std::pair<int, int*>, std::pair<char, char*>>>,
);

See Also

See also
map

◆ at_key

template<class seq , class key >
using metal::at_key = typedef typename detail::_at_key<seq, key>::type

#include <metal/map/at_key.hpp>

Description

Retrieves the value associated with some key in a Map.

Usage

For any Map m and Value k

using result = metal::at_key<m, k>;
Returns
: Value
Semantics:
If m associates keys k_1, ..., k, ..., k_n to values v_1, ..., v, ..., v_n, then
using result = v;

Example

using m = metal::map<
metal::pair<int, metal::number<sizeof(int)>>,
metal::pair<char, metal::number<sizeof(char)>>,
metal::pair<float, metal::number<sizeof(float)>>
>;
IS_SAME(metal::at_key<m, int>, metal::number<sizeof(int)>);
IS_SAME(metal::at_key<m, char>, metal::number<sizeof(char)>);
IS_SAME(metal::at_key<m, float>, metal::number<sizeof(float)>);

See Also

See also
map, has_key, insert_key, erase_key

◆ erase_key

template<class seq , class key >
using metal::erase_key = typedef metal::erase<seq, metal::order<seq, key> >

#include <metal/map/erase_key.hpp>

Description

Removes the entry associated with some key in a Map.

Usage

For any Map m and Value k

using result = metal::erase_key<m, k>;
Returns
: Map
Semantics:
If m associates keys k_1, ..., k, ..., k_n to values v_1, ..., v, ..., v_n, then

Example

using m = metal::map<
metal::pair<int, metal::number<sizeof(int)>>,
metal::pair<char, metal::number<sizeof(char)>>,
metal::pair<float, metal::number<sizeof(float)>>
>;
IS_SAME(
metal::pair<char, metal::number<sizeof(char)>>,
metal::pair<float, metal::number<sizeof(float)>>
>
);
IS_SAME(
metal::pair<int, metal::number<sizeof(int)>>,
metal::pair<float, metal::number<sizeof(float)>>
>
);
IS_SAME(
metal::pair<int, metal::number<sizeof(int)>>,
metal::pair<char, metal::number<sizeof(char)>>
>
);

See Also

See also
map, has_key, at_key, insert_key

◆ has_key

template<class seq , class key >
using metal::has_key = typedef metal::contains<metal::keys<seq>, key>

#include <metal/map/has_key.hpp>

Description

Checks whether a Map contains an entry with some key.

Usage

For any Map m and Value k

using result = metal::has_key<m, k>;
Returns
: Number
Semantics:
If m contains an entry with key k, then
using result = metal::true_;
otherwise
using result = metal::false_;

Example

See Also

See also
map, at_key, insert_key, erase_key

◆ insert_key

template<class seq , class key , class val >
using metal::insert_key = typedef metal::if_< metal::not_<metal::has_key<seq, key> >, metal::append<seq, metal::pair<key, val> >>

#include <metal/map/insert_key.hpp>

Description

Inserts a new entry in a Map.

Usage

For any Map m and Values k and v

Precondition
: k is not contained in metal::keys<m>
Returns
: Map
Semantics:
If m associates keys k_1, ..., k_n to values v_1, ..., v_n, then

Example

using m = metal::map<
metal::pair<int, metal::number<sizeof(int)>>,
metal::pair<char, metal::number<sizeof(char)>>,
metal::pair<float, metal::number<sizeof(float)>>
>;
IS_SAME(
metal::pair<int, metal::number<sizeof(int)>>,
metal::pair<char, metal::number<sizeof(char)>>,
metal::pair<float, metal::number<sizeof(float)>>,
>
);

See Also

See also
map, has_key, at_key, erase_key

◆ is_map

template<class val >
using metal::is_map = typedef typename detail::_is_map<val>::type

#include <metal/map/map.hpp>

Description

Checks whether some Value is a Map.

Usage

For any Value val

using result = metal::is_map<val>;
Returns
: Number
Semantics:
If val is a Map, then
using result = metal::true_;
otherwise
using result = metal::false_;

Example

using m = metal::map<
metal::pair<int, metal::number<sizeof(int)>>,
metal::pair<char, metal::number<sizeof(char)>>,
metal::pair<float, metal::number<sizeof(float)>>
>;
IS_SAME(metal::is_map<std::map<char, int>>, metal::false_);

See Also

See also
map, is_value, is_number, is_lambda, is_pair, is_list

◆ keys

template<class seq >
using metal::keys = typedef metal::if_<metal::is_map<seq>, metal::transform<metal::lambda<metal::first>, seq> >

#include <metal/map/keys.hpp>

Description

Returns a List of keys contained in a Map.

Usage

For any Map m

using result = metal::keys<m>;
Returns
: List
Semantics:
If m associates keys k_1, ..., k_n to values v_1, ..., v_n, then
using result = metal::list<k_1, ..., k_n>;

Example

using m = metal::map<
metal::pair<int, metal::number<sizeof(int)>>,
metal::pair<char, metal::number<sizeof(char)>>,
metal::pair<float, metal::number<sizeof(float)>>
>;

See Also

See also
map, values

◆ map

template<class... pairs>
using metal::map = typedef metal::if_<metal::is_map<metal::list<pairs...> >, metal::list<pairs...> >

#include <metal/map/map.hpp>

Description

Constructs a Map out of a sequence of Pairs.

Usage

For any Pairs pair_0, ..., pair_n-1

using result = metal::map<pair_0, ..., pair_n-1>;
Precondition
: No two Pairs have the same key
Returns
: Map

See Also

See also
is_map

◆ order

template<class seq , class key >
using metal::order = typedef metal::at_key<metal::transpose<metal::pair<metal::keys<seq>, metal::indices<seq> >>, key>

#include <metal/map/order.hpp>

Description

Returns the index of a key in a Map.

Usage

For any Map m and Value k

using result = metal::order<m, k>;
Returns
: Number
Semantics:
If m contains an entry with key k at index idx, then
using result = idx;

Example

See Also

See also
map

◆ values

template<class seq >
using metal::values = typedef metal::if_<metal::is_map<seq>, metal::transform<metal::lambda<metal::second>, seq> >

#include <metal/map/values.hpp>

Description

Returns a List of values contained in a Map.

Usage

For any Map m

using result = metal::values<m>;
Returns
: List
Semantics:
If m associates keys k_1, ..., k_n to values v_1, ..., v_n, then
using result = metal::list<v_1, ..., v_n>;

Example

using m = metal::map<
metal::pair<int, metal::number<sizeof(int)>>,
metal::pair<char, metal::number<sizeof(char)>>,
metal::pair<float, metal::number<sizeof(float)>>
>;
IS_SAME(
metal::numbers<sizeof(int), sizeof(char), sizeof(float)>
);

See Also

See also
map, keys