1 //
2 // MessagePack for C++ C++03/C++11 Adaptation
3 //
4 // Copyright (C) 2013-2016 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_CPP_CONFIG_HPP
11 #define MSGPACK_V1_CPP_CONFIG_HPP
12
13 #include "msgpack/cpp_config_decl.hpp"
14
15 #if defined(MSGPACK_USE_CPP03)
16
17 namespace msgpack {
18
19 /// @cond
MSGPACK_API_VERSION_NAMESPACE(v1)20 MSGPACK_API_VERSION_NAMESPACE(v1) {
21 /// @endcond
22
23 template <typename T>
24 struct unique_ptr : std::auto_ptr<T> {
25 explicit unique_ptr(T* p = 0) throw() : std::auto_ptr<T>(p) {}
26 unique_ptr(unique_ptr& a) throw() : std::auto_ptr<T>(a) {}
27 template<class Y>
28 unique_ptr (unique_ptr<Y>& a) throw() : std::auto_ptr<T>(a) {}
29 };
30
31 template <typename T>
32 T& move(T& t)
33 {
34 return t;
35 }
36
37 template <typename T>
38 T const& move(T const& t)
39 {
40 return t;
41 }
42
43 template <bool P, typename T>
44 struct enable_if {
45 typedef T type;
46 };
47
48 template <typename T>
49 struct enable_if<false, T> {
50 };
51
52 template<typename T, T val>
53 struct integral_constant {
54 static T const value = val;
55 typedef T value_type;
56 typedef integral_constant<T, val> type;
57 };
58
59 typedef integral_constant<bool, true> true_type;
60 typedef integral_constant<bool, false> false_type;
61
62 template<class T, class U>
63 struct is_same : false_type {};
64
65 template<class T>
66 struct is_same<T, T> : true_type {};
67
68 template<typename T>
69 struct underlying_type {
70 typedef int type;
71 };
72
73 template<class T>
74 struct is_array : false_type {};
75
76 template<class T>
77 struct is_array<T[]> : true_type {};
78
79 template<class T, std::size_t N>
80 struct is_array<T[N]> : true_type {};
81
82
83 template<class T>
84 struct remove_const {
85 typedef T type;
86 };
87 template<class T>
88 struct remove_const<const T> {
89 typedef T type;
90 };
91
92 template<class T>
93 struct remove_volatile {
94 typedef T type;
95 };
96 template<class T>
97 struct remove_volatile<volatile T> {
98 typedef T type;
99 };
100
101 template<class T>
102 struct remove_cv {
103 typedef typename msgpack::remove_volatile<
104 typename msgpack::remove_const<T>::type
105 >::type type;
106 };
107
108 namespace detail {
109
110 template<class T>
111 struct is_pointer_helper : false_type {};
112
113 template<class T>
114 struct is_pointer_helper<T*> : true_type {};
115
116 } // namespace detail
117
118 template<class T> struct is_pointer : detail::is_pointer_helper<typename remove_cv<T>::type> {};
119
120
121 /// @cond
122 } // MSGPACK_API_VERSION_NAMESPACE(v1)
123 /// @endcond
124
125 } // namespace msgpack
126
127 #endif // MSGPACK_USE_CPP03
128
129 #if __cplusplus >= 201402L
130 #if defined(_MSC_VER)
131 #define MSGPACK_DEPRECATED(msg) __declspec(deprecated(msg))
132 #else // _MSC_VER 1914+ with /Zc:__cplusplus, @see https://docs.microsoft.com/cpp/build/reference/zc-cplusplus
133 #define MSGPACK_DEPRECATED(msg) [[deprecated(msg)]]
134 #endif
135 #else // __cplusplus >= 201402L
136 #define MSGPACK_DEPRECATED(msg)
137 #endif // __cplusplus >= 201402L
138
139 #endif // MSGPACK_V1_CPP_CONFIG_HPP
140