Namespaces
Variants

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

From cppreference.net

const key_container_type & keys ( ) const noexcept ;
(seit C++23)

Gibt eine konstante Referenz auf den angepassten Schlüsselcontainer zurück. Entspricht return c. keys ; .

Inhaltsverzeichnis

Parameter

(keine)

Rückgabewert

Der zugrunde liegende Schlüsselcontainer.

Komplexität

Konstante.

Beispiel

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

Ausgabe:

[1, 2, 3]

Siehe auch

Direktzugriff auf den zugrundeliegenden Werte-Container
(öffentliche Elementfunktion)