cpp_config.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. #include "msgpack/cpp_config_decl.hpp"
  13. #include "msgpack/cpp_version.hpp"
  14. #include "msgpack/versioning.hpp"
  15. #if defined(MSGPACK_USE_CPP03)
  16. namespace msgpack {
  17. /// @cond
  18. MSGPACK_API_VERSION_NAMESPACE(v1) {
  19. /// @endcond
  20. template <typename T>
  21. struct unique_ptr : std::auto_ptr<T> {
  22. explicit unique_ptr(T* p = 0) throw() : std::auto_ptr<T>(p) {}
  23. unique_ptr(unique_ptr& a) throw() : std::auto_ptr<T>(a) {}
  24. template<class Y>
  25. unique_ptr (unique_ptr<Y>& a) throw() : std::auto_ptr<T>(a) {}
  26. };
  27. template <typename T>
  28. T& move(T& t)
  29. {
  30. return t;
  31. }
  32. template <typename T>
  33. T const& move(T const& t)
  34. {
  35. return t;
  36. }
  37. template <bool P, typename T>
  38. struct enable_if {
  39. typedef T type;
  40. };
  41. template <typename T>
  42. struct enable_if<false, T> {
  43. };
  44. template<typename T, T val>
  45. struct integral_constant {
  46. static T const value = val;
  47. typedef T value_type;
  48. typedef integral_constant<T, val> type;
  49. };
  50. typedef integral_constant<bool, true> true_type;
  51. typedef integral_constant<bool, false> false_type;
  52. template<class T, class U>
  53. struct is_same : false_type {};
  54. template<class T>
  55. struct is_same<T, T> : true_type {};
  56. template<typename T>
  57. struct underlying_type {
  58. typedef int type;
  59. };
  60. template<class T>
  61. struct is_array : false_type {};
  62. template<class T>
  63. struct is_array<T[]> : true_type {};
  64. template<class T, std::size_t N>
  65. struct is_array<T[N]> : true_type {};
  66. template<class T>
  67. struct remove_const {
  68. typedef T type;
  69. };
  70. template<class T>
  71. struct remove_const<const T> {
  72. typedef T type;
  73. };
  74. template<class T>
  75. struct remove_volatile {
  76. typedef T type;
  77. };
  78. template<class T>
  79. struct remove_volatile<volatile T> {
  80. typedef T type;
  81. };
  82. template<class T>
  83. struct remove_cv {
  84. typedef typename msgpack::remove_volatile<
  85. typename msgpack::remove_const<T>::type
  86. >::type type;
  87. };
  88. namespace detail {
  89. template<class T>
  90. struct is_pointer_helper : false_type {};
  91. template<class T>
  92. struct is_pointer_helper<T*> : true_type {};
  93. } // namespace detail
  94. template<class T> struct is_pointer : detail::is_pointer_helper<typename remove_cv<T>::type> {};
  95. /// @cond
  96. } // MSGPACK_API_VERSION_NAMESPACE(v1)
  97. /// @endcond
  98. } // namespace msgpack
  99. #endif // MSGPACK_USE_CPP03
  100. #if MSGPACK_CPP_VERSION >= 201402L
  101. #if defined(_MSC_VER)
  102. #define MSGPACK_DEPRECATED(msg) __declspec(deprecated(msg))
  103. #else
  104. #define MSGPACK_DEPRECATED(msg) [[deprecated(msg)]]
  105. #endif
  106. #else // MSGPACK_CPP_VERSION >= 201402L
  107. #define MSGPACK_DEPRECATED(msg)
  108. #endif // MSGPACK_CPP_VERSION >= 201402L
  109. #endif // MSGPACK_V1_CPP_CONFIG_HPP