classify.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 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_integral.hpp>
  17. #include <boost/atomic/detail/type_traits/is_function.hpp>
  18. #include <boost/atomic/detail/type_traits/is_floating_point.hpp>
  19. #ifdef BOOST_HAS_PRAGMA_ONCE
  20. #pragma once
  21. #endif
  22. namespace boost {
  23. namespace atomics {
  24. namespace detail {
  25. template< typename T, bool IsFunction = atomics::detail::is_function< T >::value >
  26. struct classify_pointer
  27. {
  28. typedef void* type;
  29. };
  30. template< typename T >
  31. struct classify_pointer< T, true >
  32. {
  33. typedef void type;
  34. };
  35. template< typename T, bool IsInt = atomics::detail::is_integral< T >::value, bool IsFloat = atomics::detail::is_floating_point< T >::value >
  36. struct classify
  37. {
  38. typedef void type;
  39. };
  40. template< typename T >
  41. struct classify< T, true, false > { typedef int type; };
  42. #if !defined(BOOST_ATOMIC_NO_FLOATING_POINT)
  43. template< typename T >
  44. struct classify< T, false, true > { typedef float type; };
  45. #endif
  46. template< typename T >
  47. struct classify< T*, false, false > { typedef typename classify_pointer< T >::type type; };
  48. template< >
  49. struct classify< void*, false, false > { typedef void type; };
  50. template< >
  51. struct classify< const void*, false, false > { typedef void type; };
  52. template< >
  53. struct classify< volatile void*, false, false > { typedef void type; };
  54. template< >
  55. struct classify< const volatile void*, false, false > { typedef void type; };
  56. template< typename T, typename U >
  57. struct classify< T U::*, false, false > { typedef void type; };
  58. } // namespace detail
  59. } // namespace atomics
  60. } // namespace boost
  61. #endif // BOOST_ATOMIC_DETAIL_CLASSIFY_HPP_INCLUDED_