MessagePack for C++
Loading...
Searching...
No Matches
cpp11_msgpack_tuple_decl.hpp
Go to the documentation of this file.
1//
2// MessagePack for C++ static resolution routine
3//
4// Copyright (C) 2008-2015 FURUHASHI Sadayuki and KONDO Takatoshi
5//
6// Distributed under the Boost Software License, Version 1.0.
7// (See accompanying file LICENSE_1_0.txt or copy at
8// http://www.boost.org/LICENSE_1_0.txt)
9//
10#ifndef MSGPACK_V1_CPP11_MSGPACK_TUPLE_DECL_HPP
11#define MSGPACK_V1_CPP11_MSGPACK_TUPLE_DECL_HPP
12
15#include "msgpack/meta.hpp"
16
17#include <tuple>
18
19namespace msgpack {
20
24
25namespace type {
26 // tuple
27 using std::get;
28 using std::tuple_size;
29 using std::tuple_element;
30 using std::uses_allocator;
31 using std::ignore;
32 using std::swap;
33
34 template <class... Types>
35 class tuple : public std::tuple<Types...> {
36 public:
37 using base = std::tuple<Types...>;
38
39 tuple(tuple const&) = default;
40 tuple(tuple&&) = default;
41
42 template<typename... OtherTypes>
43 tuple(OtherTypes&&... other):base(std::forward<OtherTypes>(other)...) {}
44
45 template<typename... OtherTypes>
46 tuple(tuple<OtherTypes...> const& other):base(static_cast<std::tuple<OtherTypes...> const&>(other)) {}
47 template<typename... OtherTypes>
48 tuple(tuple<OtherTypes...> && other):base(static_cast<std::tuple<OtherTypes...> &&>(other)) {}
49
50 tuple& operator=(tuple const&) = default;
51 tuple& operator=(tuple&&) = default;
52
53 template<typename... OtherTypes>
55 *static_cast<base*>(this) = static_cast<std::tuple<OtherTypes...> const&>(other);
56 return *this;
57 }
58 template<typename... OtherTypes>
60 *static_cast<base*>(this) = static_cast<std::tuple<OtherTypes...> &&>(other);
61 return *this;
62 }
63
64 template<std::size_t I>
66 get() & noexcept { return std::get<I>(static_cast<base&>(*this)); }
67
68 template<std::size_t I>
69 typename tuple_element<I, base>::type const&
70 get() const& noexcept { return std::get<I>(static_cast<base const&>(*this)); }
71
72 template<std::size_t I>
74 get() && noexcept { return std::get<I>(static_cast<base&&>(*this)); }
75
76 std::size_t size() const { return sizeof...(Types); }
77 };
78
79 template <class... Args>
80 tuple<Args...> make_tuple(Args&&... args);
81
82 template<class... Args>
83 tuple<Args&&...> forward_as_tuple (Args&&... args) noexcept;
84
85 template <class... Tuples>
86 auto tuple_cat(Tuples&&... args) ->
87 decltype(
88 std::tuple_cat(std::forward<typename std::remove_reference<Tuples>::type::base>(args)...)
89 );
90
91 template <class... Args>
92 tuple<Args&...> tie(Args&... args);
93
94} // namespace type
95
96// --- Pack from tuple to packer stream ---
97template <typename Stream, typename Tuple, std::size_t N>
98struct MsgpackTuplePacker;
99
100// --- Convert from tuple to object ---
101template <typename... Args>
102struct MsgpackTupleAs;
103
104template <typename T, typename... Args>
105struct MsgpackTupleAsImpl;
106
107template <typename Tuple, std::size_t N>
108struct MsgpackTupleConverter;
109
110// --- Convert from tuple to object with zone ---
111template <typename Tuple, std::size_t N>
112struct MsgpackTupleToObjectWithZone;
113
115} // MSGPACK_API_VERSION_NAMESPACE(v1)
117
118} // namespace msgpack
119
120#endif // MSGPACK_V1_CPP11_MSGPACK_TUPLE_DECL_HPP
Definition cpp11_msgpack_tuple_decl.hpp:35
tuple(tuple const &)=default
tuple_element< I, base >::type && get() &&noexcept
Definition cpp11_msgpack_tuple_decl.hpp:74
tuple_element< I, base >::type & get() &noexcept
Definition cpp11_msgpack_tuple_decl.hpp:66
tuple & operator=(tuple &&)=default
std::size_t size() const
Definition cpp11_msgpack_tuple_decl.hpp:76
tuple & operator=(tuple< OtherTypes... > const &other)
Definition cpp11_msgpack_tuple_decl.hpp:54
tuple(tuple< OtherTypes... > const &other)
Definition cpp11_msgpack_tuple_decl.hpp:46
tuple(tuple< OtherTypes... > &&other)
Definition cpp11_msgpack_tuple_decl.hpp:48
tuple(tuple &&)=default
tuple_element< I, base >::type const & get() const &noexcept
Definition cpp11_msgpack_tuple_decl.hpp:70
tuple & operator=(tuple const &)=default
tuple(OtherTypes &&... other)
Definition cpp11_msgpack_tuple_decl.hpp:43
tuple & operator=(tuple< OtherTypes... > &&other)
Definition cpp11_msgpack_tuple_decl.hpp:59
std::tuple< Types... > base
Definition cpp11_msgpack_tuple_decl.hpp:37
Definition adaptor_base.hpp:15
Definition cpp03_msgpack_tuple_decl.hpp:35
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition versioning.hpp:66