imgtools/imglib/boostlibrary/boost/type_traits/is_const.hpp
changeset 2 39c28ec933dd
equal deleted inserted replaced
1:820b22e13ff1 2:39c28ec933dd
       
     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 BOOST_TT_IS_CONST_HPP_INCLUDED
       
    22 #define BOOST_TT_IS_CONST_HPP_INCLUDED
       
    23 
       
    24 #include <boost/config.hpp>
       
    25 #include <boost/detail/workaround.hpp>
       
    26 
       
    27 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
       
    28 #   include <boost/type_traits/detail/cv_traits_impl.hpp>
       
    29 #   ifdef __GNUC__
       
    30 #       include <boost/type_traits/is_reference.hpp>
       
    31 #   endif
       
    32 #   if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
       
    33 #       include <boost/type_traits/remove_bounds.hpp>
       
    34 #   endif
       
    35 #else
       
    36 #   include <boost/type_traits/is_reference.hpp>
       
    37 #   include <boost/type_traits/is_array.hpp>
       
    38 #   include <boost/type_traits/detail/yes_no_type.hpp>
       
    39 #   include <boost/type_traits/detail/false_result.hpp>
       
    40 #endif
       
    41 
       
    42 // should be the last #include
       
    43 #include <boost/type_traits/detail/bool_trait_def.hpp>
       
    44 
       
    45 namespace boost {
       
    46 
       
    47 #if defined( __CODEGEARC__ )
       
    48 
       
    49 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_const,T,__is_const(T))
       
    50 
       
    51 #elif !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
       
    52 
       
    53 //* is a type T  declared const - is_const<T>
       
    54 #if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
       
    55    BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_const,T,::boost::detail::cv_traits_imp<typename remove_bounds<T>::type*>::is_const)
       
    56 #else
       
    57    BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_const,T,::boost::detail::cv_traits_imp<T*>::is_const)
       
    58 #endif
       
    59 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T&,false)
       
    60 
       
    61 #if  defined(BOOST_ILLEGAL_CV_REFERENCES)
       
    62 // these are illegal specialisations; cv-qualifies applied to
       
    63 // references have no effect according to [8.3.2p1],
       
    64 // C++ Builder requires them though as it treats cv-qualified
       
    65 // references as distinct types...
       
    66 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T& const,false)
       
    67 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T& volatile,false)
       
    68 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T& const volatile,false)
       
    69 #endif
       
    70 
       
    71 #if defined(__GNUC__) && (__GNUC__ < 3)
       
    72 // special case for gcc where illegally cv-qualified reference types can be
       
    73 // generated in some corner cases:
       
    74 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T const,!(::boost::is_reference<T>::value))
       
    75 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T volatile const,!(::boost::is_reference<T>::value))
       
    76 #endif
       
    77 
       
    78 #else
       
    79 
       
    80 namespace detail {
       
    81 
       
    82 using ::boost::type_traits::yes_type;
       
    83 using ::boost::type_traits::no_type;
       
    84 
       
    85 yes_type is_const_tester(const volatile void*);
       
    86 no_type is_const_tester(volatile void *);
       
    87 
       
    88 template <bool is_ref, bool array>
       
    89 struct is_const_helper
       
    90     : ::boost::type_traits::false_result
       
    91 {
       
    92 };
       
    93 
       
    94 template <>
       
    95 struct is_const_helper<false,false>
       
    96 {
       
    97     template <typename T> struct result_
       
    98     {
       
    99         static T* t;
       
   100         BOOST_STATIC_CONSTANT(bool, value = (
       
   101             sizeof(detail::yes_type) == sizeof(detail::is_const_tester(t))
       
   102             ));
       
   103     };
       
   104 };
       
   105 
       
   106 template <>
       
   107 struct is_const_helper<false,true>
       
   108 {
       
   109     template <typename T> struct result_
       
   110     {
       
   111         static T t;
       
   112         BOOST_STATIC_CONSTANT(bool, value = (
       
   113             sizeof(detail::yes_type) == sizeof(detail::is_const_tester(&t))
       
   114             ));
       
   115     };
       
   116 };
       
   117 
       
   118 template <typename T>
       
   119 struct is_const_impl
       
   120     : is_const_helper<
       
   121           is_reference<T>::value
       
   122         , is_array<T>::value
       
   123         >::template result_<T>
       
   124 {
       
   125 };
       
   126 
       
   127 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_const,void,false)
       
   128 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
       
   129 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_const,void const,true)
       
   130 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_const,void volatile,false)
       
   131 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_const,void const volatile,true)
       
   132 #endif
       
   133 
       
   134 } // namespace detail
       
   135 
       
   136 //* is a type T  declared const - is_const<T>
       
   137 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_const,T,::boost::detail::is_const_impl<T>::value)
       
   138 
       
   139 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
       
   140 
       
   141 } // namespace boost
       
   142 
       
   143 #include <boost/type_traits/detail/bool_trait_undef.hpp>
       
   144 
       
   145 #endif // BOOST_TT_IS_CONST_HPP_INCLUDED
       
   146