|
| 1 | +// |
| 2 | +// MessagePack for C++ static resolution routine |
| 3 | +// |
| 4 | +// Copyright (C) 2015 KONDO Takatoshi |
| 5 | +// |
| 6 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +// you may not use this file except in compliance with the License. |
| 8 | +// You may obtain a copy of the License at |
| 9 | +// |
| 10 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +// |
| 12 | +// Unless required by applicable law or agreed to in writing, software |
| 13 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +// See the License for the specific language governing permissions and |
| 16 | +// limitations under the License. |
| 17 | +// |
| 18 | + |
| 19 | +#ifndef MSGPACK_CPP11_REFERENCE_WRAPPER_HPP |
| 20 | +#define MSGPACK_CPP11_REFERENCE_WRAPPER_HPP |
| 21 | + |
| 22 | +#include "msgpack/versioning.hpp" |
| 23 | +#include "msgpack/adaptor/adaptor_base.hpp" |
| 24 | +#include "msgpack/adaptor/check_container_size.hpp" |
| 25 | + |
| 26 | +#include <memory> |
| 27 | + |
| 28 | +namespace msgpack { |
| 29 | + |
| 30 | +/// @cond |
| 31 | +MSGPACK_API_VERSION_NAMESPACE(v1) { |
| 32 | +/// @endcond |
| 33 | + |
| 34 | +namespace adaptor { |
| 35 | + |
| 36 | +template <typename T> |
| 37 | +struct pack<std::reference_wrapper<T>> { |
| 38 | + template <typename Stream> |
| 39 | + msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::reference_wrapper<T>& v) const { |
| 40 | + o.pack(v.get()); |
| 41 | + return o; |
| 42 | + } |
| 43 | +}; |
| 44 | + |
| 45 | +template <typename T> |
| 46 | +struct object<std::reference_wrapper<T> > { |
| 47 | + void operator()(msgpack::object& o, const std::reference_wrapper<T>& v) const { |
| 48 | + msgpack::adaptor::object<T>()(o, v.get()); |
| 49 | + } |
| 50 | +}; |
| 51 | + |
| 52 | +template <typename T> |
| 53 | +struct object_with_zone<std::reference_wrapper<T>> { |
| 54 | + void operator()(msgpack::object::with_zone& o, const std::reference_wrapper<T>& v) const { |
| 55 | + msgpack::adaptor::object_with_zone<T>()(o, v.get()); |
| 56 | + } |
| 57 | +}; |
| 58 | + |
| 59 | +} // namespace adaptor |
| 60 | + |
| 61 | +/// @cond |
| 62 | +} // MSGPACK_API_VERSION_NAMESPACE(v1) |
| 63 | +/// @endcond |
| 64 | + |
| 65 | +} // namespace msgpack |
| 66 | + |
| 67 | +#endif // MSGPACK_CPP11_REFERENCE_WRAPPER_HPP |
0 commit comments