winrt::single_threaded_map 函数模板 (C++/WinRT)

一个函数模板,用于创建和返回一个类型的对象,该对象实现不可观测的关联集合 (映射) 。 该对象作为 IMap 返回,这是调用返回对象的函数和属性的接口。

可以选择将现有 std::mapstd::unordered_maprvalue 传递到函数中,要么传递临时对象,要么调用左值上的 std::move

有关详细信息和代码示例,请参阅 使用 C++/WinRT 的集合

语法

template <typename K, typename V, typename Compare = std::less<K>, typename Allocator = std::allocator<std::pair<K const, V>>>
winrt::Windows::Foundation::Collections::IMap<K, V> single_threaded_map()

template <typename K, typename V, typename Compare = std::less<K>, typename Allocator = std::allocator<std::pair<K const, V>>>
winrt::Windows::Foundation::Collections::IMap<K, V> single_threaded_map(std::map<K, V, Compare, Allocator>&& values)

template <typename K, typename V, typename Hash = std::hash<K>, typename KeyEqual = std::equal_to<K>, typename Allocator = std::allocator<std::pair<K const, V>>>
winrt::Windows::Foundation::Collections::IMap<K, V> single_threaded_map(std::unordered_map<K, V, Hash, KeyEqual, Allocator>&& values)

模板参数

typename K 集合中键的类型。

typename V 集合中值的类型。

typename Compare 用于比较键的比较器的类型。

typename Allocator 从中初始化集合的关联容器的分配器的类型(如果传递一个),否则为默认分配器。

parameters

valuesstd::mapstd::unordered_map类型的右值(从中初始化集合对象的元素)的可选引用。

返回值

表示新集合对象的 IMap

要求

支持的最低 SDK:Windows SDK 版本 10.0.17763.0 (Windows 10 版本 1809)

命名空间: winrt

标头: %WindowsSdkDir%IncludeWindowsTargetPlatformVersion<>\cppwinrt\winrt\base.h (默认包含)

请参阅