//// Copyright 2017 Peter Dimov Distributed under the Boost Software License, Version 1.0. See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt //// [#map] # Map Operations, :toc: :toc-title: :idprefix: A map is a list of lists, the inner lists having at least one element (the key.) The keys of the map must be unique. ## mp_is_map template using mp_is_map = /*...*/; `mp_is_map` is `mp_true` if `M` is a map, `mp_false` otherwise. ## mp_map_find template using mp_map_find = /*...*/; `mp_map_find` is an alias for the element of the map `M` with a key `K`, or for `void`, if there is no such element. ## mp_map_contains template using mp_map_contains = mp_not, void>>; `mp_map_contains` is `mp_true` if the map `M` contains an element with a key `K`, `mp_false` otherwise. ## mp_map_insert template using mp_map_insert = mp_if< mp_map_contains>, M, mp_push_back >; Inserts the element `T` into the map `M`, if an element with a key `mp_first` is not already in `M`. ## mp_map_replace template using mp_map_replace = /*...*/; If the map `M` does not contain an element with a key `mp_first`, inserts it (using `mp_push_back`); otherwise, replaces the existing element with `T`. ## mp_map_update template class F> using mp_map_update = /*...*/; If the map `M` does not contain an element with a key `mp_first`, inserts it (using `mp_push_back`); otherwise, replaces the existing element `L` with `L>`. .Using mp_map_update to count the number of occurrences of types in a list ``` template using inc2nd = mp_int; template using count_types = mp_map_update>, inc2nd>; using L1 = mp_list; using R1 = mp_fold, count_types>; // std::tuple>, std::pair>> ``` ## mp_map_update_q template using mp_map_update_q = mp_map_update; As `mp_map_update`, but takes a quoted metafunction. ## mp_map_erase template using mp_map_erase = /*...*/; If the map `M` contains an element with a key `K`, removes it. ## mp_map_keys template using mp_map_keys = mp_transform; `mp_map_keys` returns a list of the keys of `M`. When `M` is a valid map, the keys are unique, so the result is a set.