[857] | 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_VOLATILE_HPP_INCLUDED
|
---|
| 22 | #define BOOST_TT_IS_VOLATILE_HPP_INCLUDED
|
---|
| 23 |
|
---|
| 24 | #include "boost/config.hpp"
|
---|
| 25 |
|
---|
| 26 | #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
---|
| 27 | # include "boost/type_traits/detail/cv_traits_impl.hpp"
|
---|
| 28 | #else
|
---|
| 29 | # include "boost/type_traits/is_reference.hpp"
|
---|
| 30 | # include "boost/type_traits/is_array.hpp"
|
---|
| 31 | # include "boost/type_traits/detail/yes_no_type.hpp"
|
---|
| 32 | # include "boost/type_traits/detail/false_result.hpp"
|
---|
| 33 | #endif
|
---|
| 34 |
|
---|
| 35 | // should be the last #include
|
---|
| 36 | #include "boost/type_traits/detail/bool_trait_def.hpp"
|
---|
| 37 |
|
---|
| 38 | namespace boost {
|
---|
| 39 |
|
---|
| 40 | #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
---|
| 41 |
|
---|
| 42 | //* is a type T declared volatile - is_volatile<T>
|
---|
| 43 | BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_volatile,T,::boost::detail::cv_traits_imp<T*>::is_volatile)
|
---|
| 44 | BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_volatile,T&,false)
|
---|
| 45 |
|
---|
| 46 | #if defined(__BORLANDC__) && (__BORLANDC__ < 0x600)
|
---|
| 47 | // these are illegal specialisations; cv-qualifies applied to
|
---|
| 48 | // references have no effect according to [8.3.2p1],
|
---|
| 49 | // C++ Builder requires them though as it treats cv-qualified
|
---|
| 50 | // references as distinct types...
|
---|
| 51 | BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_volatile,T& const,false)
|
---|
| 52 | BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_volatile,T& volatile,false)
|
---|
| 53 | BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_volatile,T& const volatile,false)
|
---|
| 54 | #endif
|
---|
| 55 |
|
---|
| 56 | #else
|
---|
| 57 |
|
---|
| 58 | namespace detail {
|
---|
| 59 |
|
---|
| 60 | using ::boost::type_traits::yes_type;
|
---|
| 61 | using ::boost::type_traits::no_type;
|
---|
| 62 |
|
---|
| 63 | yes_type is_volatile_tester(void const volatile*);
|
---|
| 64 | no_type is_volatile_tester(void const*);
|
---|
| 65 |
|
---|
| 66 | template <bool is_ref, bool array>
|
---|
| 67 | struct is_volatile_helper
|
---|
| 68 | : ::boost::type_traits::false_result
|
---|
| 69 | {
|
---|
| 70 | };
|
---|
| 71 |
|
---|
| 72 | template <>
|
---|
| 73 | struct is_volatile_helper<false,false>
|
---|
| 74 | {
|
---|
| 75 | template <typename T> struct result_
|
---|
| 76 | {
|
---|
| 77 | static T* t;
|
---|
| 78 | BOOST_STATIC_CONSTANT(bool, value = (
|
---|
| 79 | sizeof(detail::yes_type) == sizeof(detail::is_volatile_tester(t))
|
---|
| 80 | ));
|
---|
| 81 | };
|
---|
| 82 | };
|
---|
| 83 |
|
---|
| 84 | template <>
|
---|
| 85 | struct is_volatile_helper<false,true>
|
---|
| 86 | {
|
---|
| 87 | template <typename T> struct result_
|
---|
| 88 | {
|
---|
| 89 | static T t;
|
---|
| 90 | BOOST_STATIC_CONSTANT(bool, value = (
|
---|
| 91 | sizeof(detail::yes_type) == sizeof(detail::is_volatile_tester(&t))
|
---|
| 92 | ));
|
---|
| 93 | };
|
---|
| 94 | };
|
---|
| 95 |
|
---|
| 96 | template <typename T>
|
---|
| 97 | struct is_volatile_impl
|
---|
| 98 | : is_volatile_helper<
|
---|
| 99 | is_reference<T>::value
|
---|
| 100 | , is_array<T>::value
|
---|
| 101 | >::template result_<T>
|
---|
| 102 | {
|
---|
| 103 | };
|
---|
| 104 |
|
---|
| 105 | BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_volatile,void,false)
|
---|
| 106 | #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
|
---|
| 107 | BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_volatile,void const,false)
|
---|
| 108 | BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_volatile,void volatile,true)
|
---|
| 109 | BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_volatile,void const volatile,true)
|
---|
| 110 | #endif
|
---|
| 111 |
|
---|
| 112 | } // namespace detail
|
---|
| 113 |
|
---|
| 114 | //* is a type T declared volatile - is_volatile<T>
|
---|
| 115 | BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_volatile,T,::boost::detail::is_volatile_impl<T>::value)
|
---|
| 116 |
|
---|
| 117 | #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
---|
| 118 |
|
---|
| 119 | } // namespace boost
|
---|
| 120 |
|
---|
| 121 | #include "boost/type_traits/detail/bool_trait_undef.hpp"
|
---|
| 122 |
|
---|
| 123 | #endif // BOOST_TT_IS_VOLATILE_HPP_INCLUDED
|
---|