◐ Shell
clean mode source ↗

std::flat_map<Key,T,Compare,KeyContainer,MappedContainer>::values - cppreference.com

来自cppreference.com

const mapped_container_type& values() const noexcept;
(C++23 起)

返回对所适配的值容器的常量引用。等价于 return c.values;

参数

(无)

返回值

底层值容器。

复杂度

常数。

示例

#include <flat_map>
#include <print>
#include <type_traits>
#include <vector>

int main()
{
    std::flat_map<int, double> map{{1, 1.1}, {2, 2.2}, {3, 3.3}};

    // 默认的值容器是 std::vector:
    static_assert(std::is_same_v<decltype(map.values()), const std::vector<int>&>);

    std::println("{}", map.values());
}

输出:

参阅