2 // (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes, Howard
3 // Hinnant & John Maddock 2000. Permission to copy, use, modify,
4 // sell and distribute this software is granted provided this
5 // copyright notice appears in all copies. This software is provided
6 // "as is" without express or implied warranty, and with no claim as
7 // to its suitability for any purpose.
9 // See http://www.boost.org for most recent version including documentation.
11 #ifndef BOOST_TT_IS_CONST_HPP_INCLUDED
12 #define BOOST_TT_IS_CONST_HPP_INCLUDED
14 #include "boost/config.hpp"
16 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
17 # include "boost/type_traits/detail/cv_traits_impl.hpp"
19 # include <boost/type_traits/is_reference.hpp>
22 # include "boost/type_traits/is_reference.hpp"
23 # include "boost/type_traits/is_array.hpp"
24 # include "boost/type_traits/detail/yes_no_type.hpp"
25 # include "boost/type_traits/detail/false_result.hpp"
28 // should be the last #include
29 #include "boost/type_traits/detail/bool_trait_def.hpp"
33 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
35 //* is a type T declared const - is_const<T>
36 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_const,T,::boost::detail::cv_traits_imp<T*>::is_const)
37 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T&,false)
39 #if defined(__BORLANDC__)
40 // these are illegal specialisations; cv-qualifies applied to
41 // references have no effect according to [8.3.2p1],
42 // C++ Builder requires them though as it treats cv-qualified
43 // references as distinct types...
44 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T& const,false)
45 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T& volatile,false)
46 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T& const volatile,false)
49 #if defined(__GNUC__) && (__GNUC__ < 3)
50 // special case for gcc where illegally cv-qualified reference types can be
51 // generated in some corner cases:
52 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T const,!(::boost::is_reference<T>::value))
53 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T volatile const,!(::boost::is_reference<T>::value))
60 using ::boost::type_traits::yes_type;
61 using ::boost::type_traits::no_type;
63 yes_type is_const_tester(const volatile void*);
64 no_type is_const_tester(volatile void *);
66 template <bool is_ref, bool array>
67 struct is_const_helper
68 : ::boost::type_traits::false_result
73 struct is_const_helper<false,false>
75 template <typename T> struct result_
78 BOOST_STATIC_CONSTANT(bool, value = (
79 sizeof(detail::yes_type) == sizeof(detail::is_const_tester(t))
85 struct is_const_helper<false,true>
87 template <typename T> struct result_
90 BOOST_STATIC_CONSTANT(bool, value = (
91 sizeof(detail::yes_type) == sizeof(detail::is_const_tester(&t))
99 is_reference<T>::value
101 >::template result_<T>
105 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_const,void,false)
106 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
107 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_const,void const,true)
108 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_const,void volatile,false)
109 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_const,void const volatile,true)
112 } // namespace detail
114 //* is a type T declared const - is_const<T>
115 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_const,T,::boost::detail::is_const_impl<T>::value)
117 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
121 #include "boost/type_traits/detail/bool_trait_undef.hpp"
123 #endif // BOOST_TT_IS_CONST_HPP_INCLUDED