Namespaces
Variants

std::flat_map<Key,T,Compare,KeyContainer,MappedContainer>:: values

From cppreference.net

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

Gibt eine konstante Referenz auf den Container der angepassten Werte zurück. Entspricht return c. values ; .

Inhaltsverzeichnis

Parameter

(keine)

Rückgabewert

Der zugrundeliegende Wertecontainer.

Komplexität

Konstante.

Beispiel

#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}};
    // Der Standard-Wertecontainer ist std::vector:
    static_assert(std::is_same_v<decltype(map.values()), const std::vector<int>&>);
    std::println("{}", map.values());
}

Ausgabe:

[1.1, 2.2, 3.3]

Siehe auch

Direktzugriff auf den zugrundeliegenden Schlüssel-Container
(öffentliche Elementfunktion)