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 
14 #ifndef BOOST_ATOMIC_DETAIL_CLASSIFY_HPP_INCLUDED_
15 #define BOOST_ATOMIC_DETAIL_CLASSIFY_HPP_INCLUDED_
16 
17 #include <boost/atomic/detail/config.hpp>
18 #include <boost/atomic/detail/type_traits/is_integral.hpp>
19 #include <boost/atomic/detail/type_traits/is_function.hpp>
20 #include <boost/atomic/detail/type_traits/is_floating_point.hpp>
21 #include <boost/atomic/detail/header.hpp>
22 
23 #ifdef BOOST_HAS_PRAGMA_ONCE
24 #pragma once
25 #endif
26 
27 namespace boost {
28 namespace atomics {
29 namespace detail {
30 
31 template< typename T, bool IsFunction = atomics::detail::is_function< T >::value >
32 struct classify_pointer
33 {
34     typedef void* type;
35 };
36 
37 template< typename T >
38 struct classify_pointer< T, true >
39 {
40     typedef void type;
41 };
42 
43 template< typename T, bool IsInt = atomics::detail::is_integral< T >::value, bool IsFloat = atomics::detail::is_floating_point< T >::value >
44 struct classify
45 {
46     typedef void type;
47 };
48 
49 template< typename T >
50 struct classify< T, true, false > { typedef int type; };
51 
52 #if !defined(BOOST_ATOMIC_NO_FLOATING_POINT)
53 template< typename T >
54 struct classify< T, false, true > { typedef float type; };
55 #endif
56 
57 template< typename T >
58 struct classify< T*, false, false > { typedef typename classify_pointer< T >::type type; };
59 
60 template< >
61 struct classify< void*, false, false > { typedef void type; };
62 
63 template< >
64 struct classify< const void*, false, false > { typedef void type; };
65 
66 template< >
67 struct classify< volatile void*, false, false > { typedef void type; };
68 
69 template< >
70 struct classify< const volatile void*, false, false > { typedef void type; };
71 
72 template< typename T, typename U >
73 struct classify< T U::*, false, false > { typedef void type; };
74 
75 } // namespace detail
76 } // namespace atomics
77 } // namespace boost
78 
79 #include <boost/atomic/detail/footer.hpp>
80 
81 #endif // BOOST_ATOMIC_DETAIL_CLASSIFY_HPP_INCLUDED_
82