/extlibs/Boost/include/boost/type_traits/msvc/remove_volatile.hpp

https://bitbucket.org/hugoruscitti/pilascpp · C++ Header · 143 lines · 131 code · 9 blank · 3 comment · 0 complexity · 5a4571ca90a9b08977aa2f2a3449bdc0 MD5 · raw file

  1. // Copyright (C) 2004 Peder Holt
  2. // Use, modification and distribution is subject to the Boost Software
  3. // License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
  4. #ifndef BOOST_TYPE_TRAITS_MSVC_REMOVE_VOLATILE_HOLT_2004_0828
  5. #define BOOST_TYPE_TRAITS_MSVC_REMOVE_VOLATILE_HOLT_2004_0828
  6. #include <boost/type_traits/msvc/typeof.hpp>
  7. #include <boost/type_traits/is_volatile.hpp>
  8. #include <boost/type_traits/is_const.hpp>
  9. #include <boost/type_traits/is_pointer.hpp>
  10. #include <boost/type_traits/is_array.hpp>
  11. namespace boost {
  12. namespace detail {
  13. template<bool IsPointer,bool IsArray,bool IsConst,bool IsVolatile>
  14. struct remove_volatile_impl_typeof {
  15. template<typename T,typename ID>
  16. struct inner {
  17. typedef T type;
  18. };
  19. template<typename T>
  20. struct transform_type {
  21. typedef T type;
  22. };
  23. };
  24. template<> //Volatile
  25. struct remove_volatile_impl_typeof<false,false,false,true> {
  26. template<typename T,typename ID>
  27. struct inner {
  28. template<typename U>
  29. static msvc_register_type<U,ID> test(U volatile&(*)());
  30. static msvc_register_type<T,ID> test(...);
  31. BOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( (T(*)())(NULL) ) ));
  32. typedef typename msvc_extract_type<ID>::id2type::type type;
  33. };
  34. template<typename T>
  35. struct transform_type {
  36. typedef T& type;
  37. };
  38. };
  39. template<> //CV
  40. struct remove_volatile_impl_typeof<false,false,true,true> {
  41. template<typename T,typename ID>
  42. struct inner {
  43. template<typename U>
  44. static msvc_register_type<U const,ID> test(U const volatile&(*)());
  45. static msvc_register_type<T,ID> test(...);
  46. BOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( (T(*)())(NULL) ) ));
  47. typedef typename msvc_extract_type<ID>::id2type::type type;
  48. };
  49. template<typename T>
  50. struct transform_type {
  51. typedef T& type;
  52. };
  53. };
  54. template<> //Volatile Pointer
  55. struct remove_volatile_impl_typeof<true,false,false,true> {
  56. template<typename T,typename ID>
  57. struct inner {
  58. template<typename U>
  59. static msvc_register_type<U,ID> test(void(*)(U volatile[]));
  60. static msvc_register_type<T,ID> test(...);
  61. BOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( (void(*)(T))(NULL) ) ));
  62. typedef typename msvc_extract_type<ID>::id2type::type type;
  63. };
  64. template<typename T>
  65. struct transform_type {
  66. typedef T type[];
  67. };
  68. };
  69. template<> //CV Pointer
  70. struct remove_volatile_impl_typeof<true,false,true,true> {
  71. template<typename T,typename ID>
  72. struct inner {
  73. template<typename U>
  74. static msvc_register_type<U const,ID> test(void(*)(U const volatile[]));
  75. static msvc_register_type<T,ID> test(...);
  76. BOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( (void(*)(T))(NULL) ) ));
  77. typedef typename msvc_extract_type<ID>::id2type::type type;
  78. };
  79. template<typename T>
  80. struct transform_type {
  81. typedef T type[];
  82. };
  83. };
  84. template<> //Volatile Array
  85. struct remove_volatile_impl_typeof<false,true,false,true> {
  86. template<typename T,typename ID>
  87. struct inner {
  88. BOOST_STATIC_CONSTANT(unsigned,value=(sizeof(T)/sizeof((*((T*)NULL))[0])));
  89. template<typename U>
  90. static msvc_register_type<U[value],ID> test(void(*)(U volatile[]));
  91. static msvc_register_type<T,ID> test(...);
  92. BOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( (void(*)(T))(NULL) ) ));
  93. typedef typename msvc_extract_type<ID>::id2type::type type;
  94. };
  95. template<typename T>
  96. struct transform_type {
  97. typedef T type;
  98. };
  99. };
  100. template<> //CV Array
  101. struct remove_volatile_impl_typeof<false,true,true,true> {
  102. template<typename T,typename ID>
  103. struct inner {
  104. BOOST_STATIC_CONSTANT(unsigned,value=(sizeof(T)/sizeof((*((T*)NULL))[0])));
  105. template<typename U>
  106. static msvc_register_type<U const[value],ID> test(void(*)(U const volatile[]));
  107. static msvc_register_type<T,ID> test(...);
  108. BOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( (void(*)(T))(NULL) ) ));
  109. typedef typename msvc_extract_type<ID>::id2type::type type;
  110. };
  111. template<typename T>
  112. struct transform_type {
  113. typedef T type;
  114. };
  115. };
  116. } //namespace detail
  117. template<typename T>
  118. struct remove_volatile {
  119. typedef boost::detail::remove_volatile_impl_typeof<
  120. boost::is_pointer<T>::value,
  121. boost::is_array<T>::value,
  122. boost::is_const<T>::value,
  123. boost::is_volatile<T>::value
  124. > remove_volatile_type;
  125. typedef typename
  126. remove_volatile_type::template inner<
  127. typename remove_volatile_type::template transform_type<T>::type,
  128. remove_volatile<T>
  129. >::type
  130. type;
  131. BOOST_MPL_AUX_LAMBDA_SUPPORT(1,remove_volatile,T)
  132. };
  133. }//namespace boost
  134. #endif //BOOST_TYPE_TRAITS_MSVC_REMOVE_VOLATILE_HOLT_2004_0828