classify.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Distributed under the Boost Software License, Version 1.0.
  3. * (See accompanying file LICENSE_1_0.txt or copy at
  4. * http://www.boost.org/LICENSE_1_0.txt)
  5. *
  6. * Copyright (c) 2020-2021 Andrey Semashev
  7. */
  8. /*!
  9. * \file atomic/detail/classify.hpp
  10. *
  11. * This header contains type traits for type classification.
  12. */
  13. #ifndef BOOST_ATOMIC_DETAIL_CLASSIFY_HPP_INCLUDED_
  14. #define BOOST_ATOMIC_DETAIL_CLASSIFY_HPP_INCLUDED_
  15. #include <boost/atomic/detail/config.hpp>
  16. #include <boost/atomic/detail/type_traits/is_enum.hpp>
  17. #include <boost/atomic/detail/type_traits/is_integral.hpp>
  18. #include <boost/atomic/detail/type_traits/is_function.hpp>
  19. #include <boost/atomic/detail/type_traits/is_floating_point.hpp>
  20. #include <boost/atomic/detail/header.hpp>
  21. #ifdef BOOST_HAS_PRAGMA_ONCE
  22. #pragma once
  23. #endif
  24. namespace boost {
  25. namespace atomics {
  26. namespace detail {
  27. template< typename T, bool IsFunction = atomics::detail::is_function< T >::value >
  28. struct classify_pointer
  29. {
  30. typedef void* type;
  31. };
  32. template< typename T >
  33. struct classify_pointer< T, true >
  34. {
  35. typedef void type;
  36. };
  37. template<
  38. typename T,
  39. bool IsInt = atomics::detail::is_integral< T >::value,
  40. bool IsFloat = atomics::detail::is_floating_point< T >::value,
  41. bool IsEnum = atomics::detail::is_enum< T >::value
  42. >
  43. struct classify
  44. {
  45. typedef void type;
  46. };
  47. template< typename T >
  48. struct classify< T, true, false, false > { typedef int type; };
  49. #if !defined(BOOST_ATOMIC_NO_FLOATING_POINT)
  50. template< typename T >
  51. struct classify< T, false, true, false > { typedef float type; };
  52. #endif
  53. template< typename T >
  54. struct classify< T, false, false, true > { typedef const int type; };
  55. template< typename T >
  56. struct classify< T*, false, false, false > { typedef typename classify_pointer< T >::type type; };
  57. template< >
  58. struct classify< void*, false, false, false > { typedef void type; };
  59. template< >
  60. struct classify< const void*, false, false, false > { typedef void type; };
  61. template< >
  62. struct classify< volatile void*, false, false, false > { typedef void type; };
  63. template< >
  64. struct classify< const volatile void*, false, false, false > { typedef void type; };
  65. template< typename T, typename U >
  66. struct classify< T U::*, false, false, false > { typedef void type; };
  67. } // namespace detail
  68. } // namespace atomics
  69. } // namespace boost
  70. #include <boost/atomic/detail/footer.hpp>
  71. #endif // BOOST_ATOMIC_DETAIL_CLASSIFY_HPP_INCLUDED_