std::flat_map<Key,T,Compare,KeyContainer,MappedContainer>::keys
来自 cppreference.cn
const key_container_type& keys() const noexcept; |
(since C++23) | |
返回对适配的键容器的常量引用。等效于 return c.keys;。
目录 |
[edit] 参数
(无)
[edit] 返回值
底层的键容器。
[edit] 复杂度
常数。
[edit] 示例
运行此代码
#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]
[edit] 参见
直接访问底层的 values 容器 (public member function) |