MessagePack for C++
reference_wrapper.hpp
Go to the documentation of this file.
1 //
2 // MessagePack for C++ static resolution routine
3 //
4 // Copyright (C) 2015 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 
11 #ifndef MSGPACK_V1_TYPE_CPP11_REFERENCE_WRAPPER_HPP
12 #define MSGPACK_V1_TYPE_CPP11_REFERENCE_WRAPPER_HPP
13 
14 #include "msgpack/versioning.hpp"
17 
18 #include <memory>
19 #include <type_traits>
20 
21 namespace msgpack {
22 
26 
27 namespace adaptor {
28 
29 template <typename T>
30 struct convert<std::reference_wrapper<T>> {
31  msgpack::object const& operator()(msgpack::object const& o, std::reference_wrapper<T>& v) const {
32  msgpack::adaptor::convert<T>()(o, v.get());
33  return o;
34  }
35 };
36 
37 template <typename T>
38 struct pack<std::reference_wrapper<T>> {
39  template <typename Stream>
40  msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::reference_wrapper<T>& v) const {
41  o.pack(v.get());
42  return o;
43  }
44 };
45 
46 template <typename T>
47 struct object<std::reference_wrapper<T> > {
48  void operator()(msgpack::object& o, const std::reference_wrapper<T>& v) const {
50  }
51 };
52 
53 template <typename T>
54 struct object_with_zone<std::reference_wrapper<T>> {
55  void operator()(msgpack::object::with_zone& o, const std::reference_wrapper<T>& v) const {
57  }
58 };
59 
60 } // namespace adaptor
61 
63 } // MSGPACK_API_VERSION_NAMESPACE(v1)
65 
66 } // namespace msgpack
67 
68 #endif // MSGPACK_V1_TYPE_CPP11_REFERENCE_WRAPPER_HPP
The class template that supports continuous packing.
Definition: pack.hpp:33
packer< Stream > & pack(const T &v)
Packing function template.
Definition: adaptor_base.hpp:15
msgpack::object const & operator()(msgpack::object const &o, std::reference_wrapper< T > &v) const
Definition: reference_wrapper.hpp:31
Definition: adaptor_base.hpp:27
void operator()(msgpack::object &o, const std::reference_wrapper< T > &v) const
Definition: reference_wrapper.hpp:48
void operator()(msgpack::object::with_zone &o, const std::reference_wrapper< T > &v) const
Definition: reference_wrapper.hpp:55
Definition: adaptor_base.hpp:43
Definition: adaptor_base.hpp:38
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const std::reference_wrapper< T > &v) const
Definition: reference_wrapper.hpp:40
Definition: adaptor_base.hpp:32
Definition: object.hpp:35
Object class that corresponding to MessagePack format object.
Definition: object_fwd.hpp:75
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:66