object_fwd.hpp
Go to the documentation of this file.
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2016 FURUHASHI Sadayuki and KONDO Takatoshi
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef MSGPACK_V2_OBJECT_FWD_HPP
#define MSGPACK_V2_OBJECT_FWD_HPP
#include "msgpack/v2/object_fwd_decl.hpp"
#include "msgpack/object_fwd.hpp"
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v2) {
struct object : v1::object {
object() {}
object(v1::object const& o):v1::object(o) {}
template <typename T>
explicit object(const T& v) {
*this << v;
}
template <typename T>
object(const T& v, msgpack::zone& z):v1::object(v, z) {}
public:
template <typename T>
T& convert(T& v) const { return v1::object::convert(v); }
using v1::object::with_zone;
implicit_type convert() const;
};
#if !defined(MSGPACK_USE_CPP03)
namespace adaptor {
// If v1 has as specialization for T, then dispatch v1::adaptor::as<T>.
// So I call v1::has_as<T> meta function intentionally.
template <typename T>
struct as<T, typename std::enable_if<v1::has_as<T>::value>::type> : v1::adaptor::as<T> {
};
} // namespace adaptor
template <typename T>
struct has_as {
private:
template <typename U>
static auto check(U*) ->
typename std::enable_if<
// check v2 specialization
std::is_same<
decltype(adaptor::as<U>()(std::declval<msgpack::object>())),
U
>::value
||
// check v1 specialization
v1::has_as<U>::value,
std::true_type
>::type;
template <typename>
static std::false_type check(...);
public:
using type = decltype(check<T>(MSGPACK_NULLPTR));
static constexpr bool value = type::value;
};
#endif // !defined(MSGPACK_USE_CPP03)
} // MSGPACK_API_VERSION_NAMESPACE(v2)
} // namespace msgpack
#endif // MSGPACK_V2_OBJECT_FWD_HPP
msgpack::true_type
integral_constant< bool, true > true_type
Definition: cpp_config_decl.hpp:59
object_fwd.hpp
msgpack::adaptor::as
Definition: object_fwd_decl.hpp:62
msgpack::object::object
object(const T &v, msgpack::zone &z)
Construct object from T.
Definition: object_fwd.hpp:49
msgpack::object::object
object()
Definition: object_fwd.hpp:24
msgpack
Definition: adaptor_base.hpp:15
msgpack::object::implicit_type
Definition: object_fwd.hpp:238
msgpack::zone
Definition: cpp03_zone.hpp:22
msgpack::convert
void convert(T &v, msgpack::object const &o)
Definition: object.hpp:666
msgpack::object::convert
implicit_type convert() const
Definition: object.hpp:532
msgpack::has_as::type
decltype(check< T >(MSGPACK_NULLPTR)) type
Definition: object_fwd.hpp:65
object_fwd_decl.hpp
msgpack::enable_if
Definition: cpp_config_decl.hpp:56
msgpack::object
Object class that corresponding to MessagePack format object.
Definition: object_fwd.hpp:75
msgpack::object::type
msgpack::type::object_type type
Definition: object_fwd.hpp:92
MSGPACK_API_VERSION_NAMESPACE
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:58
msgpack::false_type
integral_constant< bool, false > false_type
Definition: cpp_config_decl.hpp:62
msgpack::has_as
Definition: object_fwd.hpp:53
msgpack::object::object
object(v1::object const &o)
Definition: object_fwd.hpp:25
MSGPACK_NULLPTR
#define MSGPACK_NULLPTR
Definition: cpp_config_decl.hpp:35
msgpack::object::convert
T & convert(T &v) const
Convert the object.
Definition: object_fwd.hpp:60
msgpack::object::object
object(const T &v)
Construct object from T.
Definition: object_fwd.hpp:35