std::flat_map<Key,T,Compare,KeyContainer,MappedContainer>::keys
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Containers library
(C++17)
(C++11)
(C++26)
(C++26)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++23)
(C++23)
(C++23)
(C++23)
(C++20)
(C++23)
Tables
std::flat_map
flat_map::keys
const key_container_type& keys() const noexcept;
(since C++23)
Return a constant reference to the adapted keys container. Equivalent to return c.keys;.
[edit] Parameters
(none)
[edit] Return value
The underlying keys container.
[edit] Complexity
Constant.
[edit] Example
Run this code
#include <flat_map> #include <print> #include <type_traits> #include <vector> int main() { std::flat_map <int, double> adaptor{{1, 1.1}, {2, 2.2}, {3, 3.3}}; // The default keys container is std::vector: static_assert(std::is_same_v <decltype(adaptor.keys()), const std::vector <int>&>); std::println ("{}", adaptor.keys()); }
Output:
[1, 2, 3]