◆ 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<typename...> struct a {};
template<typename...> struct b {};
template<typename...> 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<typename seq , typename 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

See Also

See also
map, has_key, insert_key, erase_key

◆ erase_key

template<typename seq , typename 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

See Also

See also
map, has_key, at_key, insert_key

◆ has_key

template<typename seq , typename 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<typename seq , typename key , typename 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

See Also

See also
map, has_key, at_key, erase_key

◆ is_map

template<typename 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

See Also

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

◆ keys

template<typename 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

See Also

See also
map, values

◆ map

template<typename... 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<typename seq , typename 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<typename 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

See Also

See also
map, keys