fixing stuff
[dyninst.git] / dynutil / h / dyn_detail / boost / type_traits / is_volatile.hpp
1
2 //  (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes, 
3 //      Howard Hinnant and John Maddock 2000. 
4 //  (C) Copyright Mat Marcus, Jesse Jones and Adobe Systems Inc 2001
5
6 //  Use, modification and distribution are subject to the Boost Software License,
7 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 //  http://www.boost.org/LICENSE_1_0.txt).
9 //
10 //  See http://www.boost.org/libs/type_traits for most recent version including documentation.
11
12 //    Fixed is_pointer, is_reference, is_const, is_volatile, is_same, 
13 //    is_member_pointer based on the Simulated Partial Specialization work 
14 //    of Mat Marcus and Jesse Jones. See  http://opensource.adobe.com or 
15 //    http://groups.yahoo.com/group/boost/message/5441 
16 //    Some workarounds in here use ideas suggested from "Generic<Programming>: 
17 //    Mappings between Types and Values" 
18 //    by Andrei Alexandrescu (see http://www.cuj.com/experts/1810/alexandr.html).
19
20
21 #ifndef DYN_DETAIL_BOOST_TT_IS_VOLATILE_HPP_INCLUDED
22 #define DYN_DETAIL_BOOST_TT_IS_VOLATILE_HPP_INCLUDED
23
24 #include <dyn_detail/boost/config.hpp>
25 #include <dyn_detail/boost/detail/workaround.hpp>
26
27 #ifndef DYN_DETAIL_BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
28 #   include <dyn_detail/boost/type_traits/detail/cv_traits_impl.hpp>
29 #   if DYN_DETAIL_BOOST_WORKAROUND(DYN_DETAIL_BOOST_MSVC, < 1400)
30 #       include <dyn_detail/boost/type_traits/remove_bounds.hpp>
31 #   endif
32 #else
33 #   include <dyn_detail/boost/type_traits/is_reference.hpp>
34 #   include <dyn_detail/boost/type_traits/is_array.hpp>
35 #   include <dyn_detail/boost/type_traits/detail/yes_no_type.hpp>
36 #   include <dyn_detail/boost/type_traits/detail/false_result.hpp>
37 #endif
38
39 // should be the last #include
40 #include <dyn_detail/boost/type_traits/detail/bool_trait_def.hpp>
41
42 namespace dyn_detail {
43 namespace boost {
44
45 #if defined( __CODEGEARC__ )
46 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_volatile,T,__is_volatile(T))
47 #elif !defined(DYN_DETAIL_BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
48
49 //* is a type T declared volatile - is_volatile<T>
50 #if DYN_DETAIL_BOOST_WORKAROUND(DYN_DETAIL_BOOST_MSVC, < 1400)
51    DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_volatile,T,::dyn_detail::boost::detail::cv_traits_imp<typename dyn_detail::boost::remove_bounds<T>::type*>::is_volatile)
52 #else
53    DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_volatile,T,::dyn_detail::boost::detail::cv_traits_imp<T*>::is_volatile)
54 #endif
55 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_volatile,T&,false)
56
57 #if  defined(DYN_DETAIL_BOOST_ILLEGAL_CV_REFERENCES)
58 // these are illegal specialisations; cv-qualifies applied to
59 // references have no effect according to [8.3.2p1],
60 // C++ Builder requires them though as it treats cv-qualified
61 // references as distinct types...
62 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_volatile,T& const,false)
63 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_volatile,T& volatile,false)
64 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_volatile,T& const volatile,false)
65 #endif
66
67 #else
68
69 namespace detail {
70
71         using ::dyn_detail::boost::type_traits::yes_type;
72         using ::dyn_detail::boost::type_traits::no_type;
73
74 yes_type is_volatile_tester(void const volatile*);
75 no_type is_volatile_tester(void const*);
76
77 template <bool is_ref, bool array>
78 struct is_volatile_helper
79     : ::dyn_detail::boost::type_traits::false_result
80 {
81 };
82
83 template <>
84 struct is_volatile_helper<false,false>
85 {
86     template <typename T> struct result_
87     {
88         static T* t;
89         DYN_DETAIL_BOOST_STATIC_CONSTANT(bool, value = (
90             sizeof(detail::yes_type) == sizeof(detail::is_volatile_tester(t))
91             ));
92     };
93 };
94
95 template <>
96 struct is_volatile_helper<false,true>
97 {
98     template <typename T> struct result_
99     {
100         static T t;
101         DYN_DETAIL_BOOST_STATIC_CONSTANT(bool, value = (
102             sizeof(detail::yes_type) == sizeof(detail::is_volatile_tester(&t))
103             ));
104     };
105 };
106
107 template <typename T>
108 struct is_volatile_impl
109     : is_volatile_helper<
110           is_reference<T>::value
111         , is_array<T>::value
112         >::template result_<T>
113 {
114 };
115
116 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_volatile,void,false)
117 #ifndef DYN_DETAIL_BOOST_NO_CV_VOID_SPECIALIZATIONS
118 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_volatile,void const,false)
119 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_volatile,void volatile,true)
120 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_volatile,void const volatile,true)
121 #endif
122
123 } // namespace detail
124
125 //* is a type T declared volatile - is_volatile<T>
126 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_volatile,T,::dyn_detail::boost::detail::is_volatile_impl<T>::value)
127
128 #endif // DYN_DETAIL_BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
129
130 } // namespace boost
131 } // namespace dyn_detail
132
133 #include <dyn_detail/boost/type_traits/detail/bool_trait_undef.hpp>
134
135 #endif // DYN_DETAIL_BOOST_TT_IS_VOLATILE_HPP_INCLUDED