std::flat_map<Key,T,Compare,KeyContainer,MappedContainer>::keys
来自 cppreference.cn
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}}; // The default keys container is std::vector: static_assert(std::is_same_v<decltype(adaptor.keys()), const std::vector<int>&>); std::println("{}", adaptor.keys()); }
输出
[1, 2, 3]
[编辑] 参阅
直接访问底层值容器 (public 成员函数) |