10 #ifndef MSGPACK_CPP11_MSGPACK_TUPLE_HPP 11 #define MSGPACK_CPP11_MSGPACK_TUPLE_HPP 28 using std::tuple_size;
29 using std::tuple_element;
30 using std::uses_allocator;
34 template<
class... Types >
35 class tuple :
public std::tuple<Types...> {
37 using base = std::tuple<Types...>;
43 template<
typename... OtherTypes>
44 tuple(OtherTypes&&... other):
base(std::forward<OtherTypes>(other)...) {}
46 template<
typename... OtherTypes>
48 template<
typename... OtherTypes>
54 template<
typename... OtherTypes>
56 *
static_cast<base*
>(
this) =
static_cast<std::tuple<OtherTypes...
> const&>(other);
59 template<
typename... OtherTypes>
61 *
static_cast<base*
>(
this) =
static_cast<std::tuple<OtherTypes...
> &&>(other);
65 template< std::
size_t I>
67 get() & {
return std::get<I>(*this); }
69 template< std::
size_t I>
71 get()
const& {
return std::get<I>(*this); }
73 template< std::
size_t I>
75 get() && {
return std::get<I>(*this); }
78 template <
class... Args>
80 return tuple<Args...>(args...);
83 template<
class... Args>
85 return tuple<Args&&...>(std::forward<Args>(args)...);
88 template <
class... Tuples>
91 std::tuple_cat(std::forward<
typename std::remove_reference<Tuples>::type::base>(args)...)
93 return std::tuple_cat(std::forward<
typename std::remove_reference<Tuples>::type::base>(args)...);
95 template <
class... Args>
97 return tuple<Args&...>(args...);
102 template <
typename Stream,
typename Tuple, std::
size_t N>
108 o.
pack(type::get<N-1>(v));
112 template <
typename Stream,
typename Tuple>
117 o.
pack(type::get<0>(v));
121 template <
typename Stream,
typename Tuple>
131 template <
typename... Args>
133 template <
typename Stream>
147 template <
typename... Args>
150 template <
typename T,
typename... Args>
159 template <
typename... Args>
173 template <
typename Tuple, std::
size_t N>
179 o.
via.
array.
ptr[N-1].
convert<
typename std::remove_reference<decltype(type::get<N-1>(v))>::type>(type::get<N-1>(v));
183 template <
typename Tuple>
188 o.
via.
array.
ptr[0].
convert<
typename std::remove_reference<decltype(type::get<0>(v))>::type>(type::get<0>(v));
192 template <
typename Tuple>
202 template <
typename... Args>
203 struct as<
msgpack::
type::tuple<Args...>, typename std::enable_if<msgpack::all_of<msgpack::has_as, Args...>::value>::type> {
212 template <
typename... Args>
227 template <
typename Tuple, std::
size_t N>
237 template <
typename Tuple>
246 template <
typename Tuple>
256 template <
typename... Args>
276 #endif // MSGPACK_CPP11_MSGPACK_TUPLE_HPP T & convert(T &v) const
Convert the object.
Definition: object.hpp:520
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const msgpack::type::tuple< Args... > &v) const
Definition: cpp11_msgpack_tuple.hpp:134
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:58
auto tuple_cat(Tuples &&... args) -> decltype(std::tuple_cat(std::forward< typename std::remove_reference< Tuples >::type::base >(args)...))
Definition: cpp11_msgpack_tuple.hpp:89
uint32_t size
Definition: object_fwd.hpp:50
tuple(tuple const &)=default
void * allocate_align(size_t size, size_t align=MSGPACK_ZONE_ALIGN)
Definition: cpp03_zone.hpp:248
tuple< Args &... > tie(Args &... args)
Definition: cpp11_msgpack_tuple.hpp:96
static msgpack::type::tuple< Args... > as(msgpack::object const &o)
Definition: cpp11_msgpack_tuple.hpp:161
static void convert(msgpack::object::with_zone &, const Tuple &)
Definition: cpp11_msgpack_tuple.hpp:248
Definition: object_fwd.hpp:82
Definition: cpp03_msgpack_tuple.hpp:35
union_type via
Definition: object_fwd.hpp:123
std::enable_if< msgpack::has_as< T >::value, T >::type as() const
Get value as T.
Definition: object.hpp:558
static void convert(msgpack::object::with_zone &o, const Tuple &v)
Definition: cpp11_msgpack_tuple.hpp:229
tuple(tuple< OtherTypes... > const &other)
Definition: cpp11_msgpack_tuple.hpp:47
msgpack::zone & zone
Definition: object_fwd.hpp:262
void operator()(msgpack::object::with_zone &o, msgpack::type::tuple< Args... > const &v) const
Definition: cpp11_msgpack_tuple.hpp:258
tuple & operator=(tuple< OtherTypes... > &&other)
Definition: cpp11_msgpack_tuple.hpp:60
msgpack::object * ptr
Definition: object_fwd.hpp:51
static void convert(msgpack::object const &o, Tuple &v)
Definition: cpp11_msgpack_tuple.hpp:185
packer< Stream > & pack_array(uint32_t n)
Packing array header and size.
Definition: pack.hpp:1163
Definition: adaptor_base.hpp:15
static void pack(msgpack::packer< Stream > &o, const Tuple &v)
Definition: cpp11_msgpack_tuple.hpp:104
static void convert(msgpack::object::with_zone &o, const Tuple &v)
Definition: cpp11_msgpack_tuple.hpp:239
tuple & operator=(tuple const &)=default
Definition: cpp11_msgpack_tuple.hpp:228
void convert(T &v, msgpack::object const &o)
Definition: object.hpp:631
Definition: object_fwd.hpp:260
packer< Stream > & pack(const T &v)
Packing function template.
Definition: cpp11_msgpack_tuple.hpp:103
Definition: cpp03_msgpack_tuple.hpp:9178
msgpack::type::tuple< Args... > operator()(msgpack::object const &o) const
Definition: cpp11_msgpack_tuple.hpp:204
std::tuple< Types... > base
Definition: cpp11_msgpack_tuple.hpp:37
Definition: adaptor_base.hpp:45
msgpack::object const & operator()(msgpack::object const &o, msgpack::type::tuple< Args... > &v) const
Definition: cpp11_msgpack_tuple.hpp:214
tuple make_tuple()
Definition: cpp03_msgpack_tuple.hpp:10388
Definition: object_fwd.hpp:253
tuple & operator=(tuple< OtherTypes... > const &other)
Definition: cpp11_msgpack_tuple.hpp:55
static void pack(msgpack::packer< Stream > &, const Tuple &)
Definition: cpp11_msgpack_tuple.hpp:123
Definition: adaptor_base.hpp:34
tuple(tuple< OtherTypes... > &&other)
Definition: cpp11_msgpack_tuple.hpp:49
msgpack::object_array array
Definition: object_fwd.hpp:115
void pack(msgpack::packer< Stream > &o, const T &v)
Definition: object.hpp:638
static msgpack::type::tuple as(msgpack::object const &)
Definition: cpp11_msgpack_tuple.hpp:168
static void pack(msgpack::packer< Stream > &o, const Tuple &v)
Definition: cpp11_msgpack_tuple.hpp:114
tuple(OtherTypes &&... other)
Definition: cpp11_msgpack_tuple.hpp:44
Object class that corresponding to MessagePack format object.
Definition: object_fwd.hpp:106
static void convert(msgpack::object const &o, Tuple &v)
Definition: cpp11_msgpack_tuple.hpp:175
Definition: cpp11_msgpack_tuple.hpp:148
msgpack::type::object_type type
Definition: object_fwd.hpp:122
Definition: object_fwd.hpp:39
static void convert(msgpack::object const &, Tuple &)
Definition: cpp11_msgpack_tuple.hpp:194
tuple< Args &&... > forward_as_tuple(Args &&... args) noexcept
Definition: cpp11_msgpack_tuple.hpp:84
Definition: cpp11_msgpack_tuple.hpp:35
The class template that supports continuous packing.
Definition: adaptor_base.hpp:22
static msgpack::type::tuple< T, Args... > as(msgpack::object const &o)
Definition: cpp11_msgpack_tuple.hpp:152
Definition: cpp11_msgpack_tuple.hpp:174
Definition: cpp11_msgpack_tuple.hpp:151
Definition: adaptor_base.hpp:29