CppWAMP
C++11 client library for the WAMP protocol
|
Go to the documentation of this file.
7 #ifndef CPPWAMP_TYPES_UNORDEREDMAP_HPP
8 #define CPPWAMP_TYPES_UNORDEREDMAP_HPP
16 #include <unordered_map>
19 #include "../error.hpp"
20 #include "../variant.hpp"
31 std::unordered_map<String, T>& map)
33 const auto& variant = conv.
variant();
37 "to std::unordered_map");
40 std::unordered_map<String, T> newMap;
41 for (
const auto& kv: variant.as<
Object>())
45 newMap.emplace(kv.first, kv.second.to<T>());
49 std::string msg = e.what();
50 msg +=
" (for variant member \"" + kv.first +
"\")";
54 map = std::move(newMap);
63 std::unordered_map<String, T>& map)
66 for (
const auto& kv: map)
70 conv.
variant() = std::move(obj);
76 #endif // CPPWAMP_TYPES_UNORDEREDMAP_HPP
const Variant & variant() const
Returns a constant reference to the wrapped variant.
Definition: variant.hpp:1384
std::map< String, Variant > Object
Variant bound type for maps of variants.
Definition: variantdefs.hpp:52
Variant & variant()
Returns a reference to the wrapped variant.
Definition: variant.hpp:1208
Definition: anyhandler.hpp:36
Wrapper around a destination Variant, used for conversions.
Definition: variant.hpp:604
Wrapper around a source Variant, used for conversions.
Definition: variant.hpp:650
void convert(TConverter &c, TValue &val)
General function for converting custom types to/from Variant.
Definition: variant.hpp:709
Exception type thrown when converting a Variant to an invalid type.
Definition: error.hpp:106
static Variant from(TValue &&value)
Constructs a variant from a custom type.
Definition: variant.hpp:744