MessagePack for C++
cpp_config.hpp
Go to the documentation of this file.
1 //
2 // MessagePack for C++ C++03/C++11 Adaptation
3 //
4 // Copyright (C) 2013 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_CPP_CONFIG_HPP
11 #define MSGPACK_CPP_CONFIG_HPP
12 
13 #include "msgpack/versioning.hpp"
14 
15 #if !defined(MSGPACK_USE_CPP03)
16 # if defined(_MSC_VER)
17 # if _MSC_VER < 1900
18 # define MSGPACK_USE_CPP03
19 # endif
20 # elif (__cplusplus < 201103L)
21 # define MSGPACK_USE_CPP03
22 # endif
23 #endif // MSGPACK_USE_CPP03
24 
25 
26 
27 #if defined(MSGPACK_USE_CPP03)
28 
29 #if !defined(nullptr)
30 # if _MSC_VER < 1600
31 # define nullptr (0)
32 # endif
33 #endif
34 
35 #include <memory>
36 
37 namespace msgpack {
38 
42 
43 template <typename T>
44 struct unique_ptr : std::auto_ptr<T> {
45  explicit unique_ptr(T* p = 0) throw() : std::auto_ptr<T>(p) {}
46  unique_ptr(unique_ptr& a) throw() : std::auto_ptr<T>(a) {}
47  template<class Y>
48  unique_ptr (unique_ptr<Y>& a) throw() : std::auto_ptr<T>(a) {}
49 };
50 
51 template <typename T>
52 T& move(T& t)
53 {
54  return t;
55 }
56 
57 template <typename T>
58 T const& move(T const& t)
59 {
60  return t;
61 }
62 
63 template <bool P, typename T = void>
64 struct enable_if {
65  typedef T type;
66 };
67 
68 template <typename T>
69 struct enable_if<false, T> {
70 };
71 
72 template<typename T, T val>
74  static T const value = val;
75  typedef T value_type;
77 };
78 
81 
82 template<class T, class U>
83 struct is_same : false_type {};
84 
85 template<class T>
86 struct is_same<T, T> : true_type {};
87 
89 } // MSGPACK_API_VERSION_NAMESPACE(v1)
91 
92 } // namespace msgpack
93 
94 
95 #else // MSGPACK_USE_CPP03
96 
97 #include <memory>
98 #include <tuple>
99 
100 namespace msgpack {
104 
105  // unique_ptr
106  using std::unique_ptr;
107  // using std::make_unique; // since C++14
108  using std::hash;
109 
110  // utility
111  using std::move;
112  using std::swap;
113  using std::enable_if;
114  using std::is_same;
115 
117 } // MSGPACK_API_VERSION_NAMESPACE(v1)
119 } // namespace msgpack
120 
121 
122 #endif // MSGPACK_USE_CPP03
123 
124 #endif /* msgpack/cpp_config.hpp */
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:58
integral_constant< T, val > type
Definition: cpp_config.hpp:76
integral_constant< bool, true > true_type
Definition: cpp_config.hpp:79
unique_ptr(unique_ptr &a)
Definition: cpp_config.hpp:46
Definition: cpp_config.hpp:83
Definition: adaptor_base.hpp:15
T const & move(T const &t)
Definition: cpp_config.hpp:58
Definition: cpp_config.hpp:44
T type
Definition: cpp_config.hpp:65
Definition: cpp_config.hpp:73
T value_type
Definition: cpp_config.hpp:75
unique_ptr(unique_ptr< Y > &a)
Definition: cpp_config.hpp:48
Definition: cpp_config.hpp:64
unique_ptr(T *p=0)
Definition: cpp_config.hpp:45
integral_constant< bool, false > false_type
Definition: cpp_config.hpp:80
T & move(T &t)
Definition: cpp_config.hpp:52