classify.hpp 2.1 KB

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