CppWAMP
C++11 client library for the WAMP protocol
|
Go to the documentation of this file.
7 #ifndef CPPWAMP_TYPES_ARRAY_HPP
8 #define CPPWAMP_TYPES_ARRAY_HPP
18 #include "../error.hpp"
19 #include "../variant.hpp"
28 template <
typename T, std::
size_t Size>
32 const auto& variant = conv.
variant();
33 if (variant.is<
Array>() ==
false)
39 std::array<T, Size> newArray;
40 const auto& variantArray = variant.as<
Array>();
41 if (variantArray.size() != Size)
44 "of std::array<T," + std::to_string(Size) +
">");
47 for (Array::size_type i=0; i<variantArray.size(); ++i)
51 newArray[i] = variantArray[i].to<T>();
55 std::string msg = e.what();
56 msg +=
" (for element #" + std::to_string(i) +
")";
60 array = std::move(newArray);
67 template <
typename T, std::
size_t Size>
72 for (
const auto& elem:
array)
76 conv.
variant() = std::move(variantArray);
81 #endif // CPPWAMP_TYPES_ARRAY_HPP
const Variant & variant() const
Returns a constant reference to the wrapped variant.
Definition: variant.hpp:1384
@ array
For Variant::Array.
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
std::vector< Variant > Array
Variant bound type for arrays of variants.
Definition: variantdefs.hpp:51
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