]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/function_types/include/boost/function_types/detail/cv_traits.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / function_types / include / boost / function_types / detail / cv_traits.hpp
CommitLineData
7c673cae
FG
1
2// (C) Copyright Tobias Schwinger
3//
4// Use modification and distribution are subject to the boost Software License,
5// Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt).
6
7//------------------------------------------------------------------------------
8
9#ifndef BOOST_FT_DETAIL_CV_TRAITS_HPP_INCLUDED
10#define BOOST_FT_DETAIL_CV_TRAITS_HPP_INCLUDED
11
12#include <cstddef>
13#include <boost/detail/workaround.hpp>
14
15#if BOOST_WORKAROUND(__BORLANDC__, <= 0x582)
16# include <boost/type_traits/remove_cv.hpp>
17# include <boost/type_traits/remove_pointer.hpp>
18# include <boost/type_traits/remove_reference.hpp>
19#endif
20
21#include <boost/function_types/property_tags.hpp>
22
23namespace boost { namespace function_types { namespace detail {
24
25#if !BOOST_WORKAROUND(__BORLANDC__, <= 0x582)
26
27template<typename T> struct cv_traits
28{ typedef non_cv tag; typedef T type; };
29template<typename T> struct cv_traits<T &>
30{ typedef non_cv tag; typedef T type; };
31template<typename T> struct cv_traits<T *>
32{ typedef non_cv tag; typedef T type; };
33template<typename T> struct cv_traits<T * const>
34{ typedef non_cv tag; typedef T type; };
35template<typename T> struct cv_traits<T * volatile>
36{ typedef non_cv tag; typedef T type; };
37template<typename T> struct cv_traits<T * const volatile>
38{ typedef non_cv tag; typedef T type; };
39
40template<typename T> struct cv_traits<T const>
41{ typedef const_non_volatile tag; typedef T type; };
42template<typename T> struct cv_traits<T const &>
43{ typedef const_non_volatile tag; typedef T type; };
44template<typename T> struct cv_traits<T const *>
45{ typedef const_non_volatile tag; typedef T type; };
46template<typename T> struct cv_traits<T const * const>
47{ typedef const_non_volatile tag; typedef T type; };
48template<typename T> struct cv_traits<T const * volatile>
49{ typedef const_non_volatile tag; typedef T type; };
50template<typename T> struct cv_traits<T const * const volatile>
51{ typedef const_non_volatile tag; typedef T type; };
52
53template<typename T> struct cv_traits<T volatile>
54{ typedef volatile_non_const tag; typedef T type; };
55template<typename T> struct cv_traits<T volatile &>
56{ typedef volatile_non_const tag; typedef T type; };
57template<typename T> struct cv_traits<T volatile *>
58{ typedef volatile_non_const tag; typedef T type; };
59template<typename T> struct cv_traits<T volatile * const>
60{ typedef volatile_non_const tag; typedef T type; };
61template<typename T> struct cv_traits<T volatile * volatile>
62{ typedef volatile_non_const tag; typedef T type; };
63template<typename T> struct cv_traits<T volatile * const volatile>
64{ typedef volatile_non_const tag; typedef T type; };
65
66template<typename T> struct cv_traits<T const volatile>
67{ typedef cv_qualified tag; typedef T type; };
68template<typename T> struct cv_traits<T const volatile &>
69{ typedef cv_qualified tag; typedef T type; };
70template<typename T> struct cv_traits<T const volatile *>
71{ typedef cv_qualified tag; typedef T type; };
72template<typename T> struct cv_traits<T const volatile * const>
73{ typedef cv_qualified tag; typedef T type; };
74template<typename T> struct cv_traits<T const volatile * volatile>
75{ typedef cv_qualified tag; typedef T type; };
76template<typename T> struct cv_traits<T const volatile * const volatile>
77{ typedef cv_qualified tag; typedef T type; };
78
79#else
80template<std::size_t> struct cv_tag_impl;
81
82template<> struct cv_tag_impl<1> { typedef non_cv type;};
83template<> struct cv_tag_impl<2> { typedef const_non_volatile type; };
84template<> struct cv_tag_impl<3> { typedef volatile_non_const type; };
85template<> struct cv_tag_impl<4> { typedef cv_qualified type; };
86
87typedef char (& case_1)[1];
88typedef char (& case_2)[2];
89typedef char (& case_3)[3];
90typedef char (& case_4)[4];
91
92template<typename T> case_1 switch_cv(T *);
93template<typename T> case_2 switch_cv(T const *);
94template<typename T> case_3 switch_cv(T volatile *);
95template<typename T> case_4 switch_cv(T const volatile *);
96
97template<typename T> T * ref_to_ptr(T &);
98template<typename T> T const * ref_to_ptr(T const &);
99template<typename T> T volatile * ref_to_ptr(T volatile &);
100template<typename T> T const volatile * ref_to_ptr(T const volatile &);
101
102template<typename T> T * ref_to_ptr(T * const volatile &);
103
104template<typename T>
105struct cv_code
106{
107 static T _t;
108 BOOST_STATIC_CONSTANT(std::size_t, value =
109 sizeof(::boost::function_types::detail::switch_cv(
110 ::boost::function_types::detail::ref_to_ptr(_t) ) ));
111};
112
113template<typename T> struct cv_traits
114{
115 typedef typename boost::function_types::detail::cv_tag_impl<
116 ::boost::function_types::detail::cv_code<T>::value >::type
117 tag;
118
119 // may require Boost.TypeTraits broken compiler specializations
120 // to work
121 typedef typename boost::remove_cv<
122 typename boost::remove_pointer<
123 typename boost::remove_reference<T>::type
124 >::type
125 >::type type;
126};
127#endif
128
129} } } // namespace boost::function_types::detail
130
131#endif
132