cpp_config.hpp 2.8 KB

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