一个函数模板,该模板创建并返回实现不可观测关联集合(map)的类型的对象。 对象作为 IMap 返回,这是调用返回对象的函数和属性的接口。
可以选择将现有的 std::map 或 std::unordered_map右值传递到函数中,要么传递临时对象,也可以调用 lvalue 上的 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
从中初始化集合的关联容器的分配器的类型(如果传递一个),否则为默认分配器。
参数
values
对 std::map 或 std::unordered_map 类型的右值的可选引用,从中初始化集合对象的元素。
返回值
表示新集合对象的 IMap 。
要求
支持的最低 SDK: Windows SDK 版本 10.0.17763.0 (Windows 10 版本 1809)
命名空间: winrt
标头: %WindowsSdkDir%Include<WindowsTargetPlatformVersion>\cppwinrt\winrt\Windows.Foundation.Collections.h