MessagePack for C++
object_fwd.hpp
Go to the documentation of this file.
1 //
2 // MessagePack for C++ static resolution routine
3 //
4 // Copyright (C) 2008-2018 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 
11 #ifndef MSGPACK_V3_OBJECT_FWD_HPP
12 #define MSGPACK_V3_OBJECT_FWD_HPP
13 
15 #include "msgpack/object_fwd.hpp"
16 
17 namespace msgpack {
18 
22 
23 #if !defined(MSGPACK_USE_CPP03)
24 
25 namespace adaptor {
26 
27 // If v2 has as specialization for T, then dispatch v2::adaptor::as<T>.
28 // So I call v2::has_as<T> meta function intentionally.
29 template <typename T>
30 struct as<T, typename std::enable_if<v2::has_as<T>::value>::type> : v2::adaptor::as<T> {
31 };
32 
33 } // namespace adaptor
34 
35 template <typename T>
36 struct has_as {
37 private:
38  template <typename U>
39  static auto check(U*) ->
40  typename std::enable_if<
41  // check v3 specialization
42  std::is_same<
43  decltype(adaptor::as<U>()(std::declval<msgpack::object>())),
44  U
45  >::value
46  ||
47  // check v2 specialization
48  v2::has_as<U>::value
49  ||
50  // check v1 specialization
51  v1::has_as<U>::value,
52  std::true_type
53  >::type;
54  template <typename...>
55  static std::false_type check(...);
56 public:
57  using type = decltype(check<T>(MSGPACK_NULLPTR));
58  static constexpr bool value = type::value;
59 };
60 
61 #endif // !defined(MSGPACK_USE_CPP03)
62 
63 
65 } // MSGPACK_API_VERSION_NAMESPACE(v3)
67 
68 } // namespace msgpack
69 
70 #endif // MSGPACK_V3_OBJECT_FWD_HPP
Definition: adaptor_base.hpp:15
Definition: object_fwd_decl.hpp:61
Definition: object_fwd.hpp:53
static constexpr bool value
Definition: object_fwd.hpp:66
decltype(check< T >(MSGPACK_NULLPTR)) type
Definition: object_fwd.hpp:65
#define MSGPACK_NULLPTR
Definition: cpp_config_decl.hpp:85
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:66