element_type.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. Copyright 2015 Glen Joseph Fernandes
  3. (glenjofe@gmail.com)
  4. Distributed under the Boost Software License, Version 1.0.
  5. (http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. #ifndef BOOST_ALIGN_DETAIL_ELEMENT_TYPE_HPP
  8. #define BOOST_ALIGN_DETAIL_ELEMENT_TYPE_HPP
  9. #include <boost/config.hpp>
  10. #if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
  11. #include <type_traits>
  12. #else
  13. #include <cstddef>
  14. #endif
  15. namespace boost {
  16. namespace alignment {
  17. namespace detail {
  18. #if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
  19. using std::remove_reference;
  20. using std::remove_all_extents;
  21. using std::remove_cv;
  22. #else
  23. template<class T>
  24. struct remove_reference {
  25. typedef T type;
  26. };
  27. template<class T>
  28. struct remove_reference<T&> {
  29. typedef T type;
  30. };
  31. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  32. template<class T>
  33. struct remove_reference<T&&> {
  34. typedef T type;
  35. };
  36. #endif
  37. template<class T>
  38. struct remove_all_extents {
  39. typedef T type;
  40. };
  41. template<class T>
  42. struct remove_all_extents<T[]> {
  43. typedef typename remove_all_extents<T>::type type;
  44. };
  45. template<class T, std::size_t N>
  46. struct remove_all_extents<T[N]> {
  47. typedef typename remove_all_extents<T>::type type;
  48. };
  49. template<class T>
  50. struct remove_cv {
  51. typedef T type;
  52. };
  53. template<class T>
  54. struct remove_cv<const T> {
  55. typedef T type;
  56. };
  57. template<class T>
  58. struct remove_cv<volatile T> {
  59. typedef T type;
  60. };
  61. template<class T>
  62. struct remove_cv<const volatile T> {
  63. typedef T type;
  64. };
  65. #endif
  66. template<class T>
  67. struct element_type {
  68. typedef typename remove_cv<typename remove_all_extents<typename
  69. remove_reference<T>::type>::type>::type type;
  70. };
  71. } /* detail */
  72. } /* alignment */
  73. } /* boost */
  74. #endif