[flat.map.cons]

# 23 Containers library [[containers]](./#containers)

## 23.6 Container adaptors [[container.adaptors]](container.adaptors#flat.map.cons)

### 23.6.8 Class template flat_map [[flat.map]](flat.map#cons)

#### 23.6.8.3 Constructors [flat.map.cons]

[ð](#lib:flat_map,constructor)

`constexpr flat_map(key_container_type key_cont, mapped_container_type mapped_cont,
                   const key_compare& comp = key_compare());
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L17425)

*Effects*: Initializes*c*.keys with std​::​move(key_cont),*c*.values with std​::​move(mapped_cont), and*compare* with comp;
sorts the range [begin(), end()) with respect to value_comp(); and
finally erases the duplicate elements as if by:auto zv = views::zip(*c*.keys, *c*.values);auto it = ranges::unique(zv, *key-equiv*(*compare*)).begin();auto dist = distance(zv.begin(), it);*c*.keys.erase(*c*.keys.begin() + dist, *c*.keys.end());*c*.values.erase(*c*.values.begin() + dist, *c*.values.end());

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L17441)

*Complexity*: Linear in N if the container arguments are already sorted
with respect to value_comp() and otherwise NlogN,
where N is the value of key_cont.size() before this call[.](#2.sentence-1)

[ð](#lib:flat_map,constructor_)

`constexpr flat_map(sorted_unique_t, key_container_type key_cont, mapped_container_type mapped_cont,
                   const key_compare& comp = key_compare());
`

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L17455)

*Effects*: Initializes*c*.keys with std​::​move(key_cont),*c*.values with std​::​move(mapped_cont), and*compare* with comp[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L17462)

*Complexity*: Constant[.](#4.sentence-1)
