std::flat_map<Key,T,Compare,KeyContainer,MappedContainer>:: keys
From cppreference.net
C++
Containers library
|
(C++17)
|
||||
| Sequence | ||||
|
(C++11)
|
||||
|
(C++26)
|
||||
|
(C++26)
|
||||
|
(C++11)
|
||||
| Associative | ||||
| Unordered associative | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| Adaptors | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
| Views | ||||
|
(C++20)
|
||||
|
(C++23)
|
||||
| Tables | ||||
| Iterator invalidation | ||||
| Member function table | ||||
| Non-member function table |
std::flat_map
|
const
key_container_type
&
keys
(
)
const
noexcept
;
|
(C++23 起) | |
返回被适配键容器的常量引用。等价于 return c. keys ; 。
目录 |
参数
(无)
返回值
底层键容器。
复杂度
常量。
示例
运行此代码
#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}}; // 默认键容器为 std::vector: static_assert(std::is_same_v<decltype(adaptor.keys()), const std::vector<int>&>); std::println("{}", adaptor.keys()); }
输出:
[1, 2, 3]
参见
|
直接访问底层值容器
(公开成员函数) |