Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 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_lvalue_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 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 21 | #ifndef NDNBOOST_TT_IS_LVALUE_REFERENCE_HPP_INCLUDED |
| 22 | #define NDNBOOST_TT_IS_LVALUE_REFERENCE_HPP_INCLUDED |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 23 | |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 24 | #include <ndnboost/type_traits/config.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 25 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 26 | #ifdef NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 27 | # include <ndnboost/type_traits/detail/yes_no_type.hpp> |
| 28 | # include <ndnboost/type_traits/detail/wrap.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 29 | #endif |
| 30 | |
| 31 | // should be the last #include |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 32 | #include <ndnboost/type_traits/detail/bool_trait_def.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 33 | |
| 34 | namespace ndnboost { |
| 35 | |
| 36 | #if defined( __CODEGEARC__ ) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 37 | NDNBOOST_TT_AUX_BOOL_TRAIT_DEF1(is_lvalue_reference,T,__is_reference(T)) |
| 38 | #elif !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 39 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 40 | NDNBOOST_TT_AUX_BOOL_TRAIT_DEF1(is_lvalue_reference,T,false) |
| 41 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_lvalue_reference,T&,true) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 42 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 43 | #if defined(NDNBOOST_ILLEGAL_CV_REFERENCES) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 44 | // these are illegal specialisations; cv-qualifies applied to |
| 45 | // references have no effect according to [8.3.2p1], |
| 46 | // C++ Builder requires them though as it treats cv-qualified |
| 47 | // references as distinct types... |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 48 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_lvalue_reference,T& const,true) |
| 49 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_lvalue_reference,T& volatile,true) |
| 50 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_lvalue_reference,T& const volatile,true) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 51 | #endif |
| 52 | |
| 53 | #if defined(__GNUC__) && (__GNUC__ < 3) |
| 54 | // these allow us to work around illegally cv-qualified reference |
| 55 | // types. |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 56 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_lvalue_reference,T const ,::ndnboost::is_lvalue_reference<T>::value) |
| 57 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_lvalue_reference,T volatile ,::ndnboost::is_lvalue_reference<T>::value) |
| 58 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_lvalue_reference,T const volatile ,::ndnboost::is_lvalue_reference<T>::value) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 59 | // However, the above specializations confuse gcc 2.96 unless we also |
| 60 | // supply these specializations for array types |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 61 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,unsigned long N,is_lvalue_reference,T[N],false) |
| 62 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,unsigned long N,is_lvalue_reference,const T[N],false) |
| 63 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,unsigned long N,is_lvalue_reference,volatile T[N],false) |
| 64 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,unsigned long N,is_lvalue_reference,const volatile T[N],false) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 65 | #endif |
| 66 | |
| 67 | #else |
| 68 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 69 | #ifdef NDNBOOST_MSVC |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 70 | # pragma warning(push) |
| 71 | # pragma warning(disable: 4181 4097) |
| 72 | #endif |
| 73 | |
| 74 | namespace detail { |
| 75 | |
| 76 | using ::ndnboost::type_traits::yes_type; |
| 77 | using ::ndnboost::type_traits::no_type; |
| 78 | using ::ndnboost::type_traits::wrap; |
| 79 | |
| 80 | template <class T> T&(* is_lvalue_reference_helper1(wrap<T>) )(wrap<T>); |
| 81 | char is_lvalue_reference_helper1(...); |
| 82 | |
| 83 | template <class T> no_type is_lvalue_reference_helper2(T&(*)(wrap<T>)); |
| 84 | yes_type is_lvalue_reference_helper2(...); |
| 85 | |
| 86 | template <typename T> |
| 87 | struct is_lvalue_reference_impl |
| 88 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 89 | NDNBOOST_STATIC_CONSTANT( |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 90 | bool, value = sizeof( |
| 91 | ::ndnboost::detail::is_lvalue_reference_helper2( |
| 92 | ::ndnboost::detail::is_lvalue_reference_helper1(::ndnboost::type_traits::wrap<T>()))) == 1 |
| 93 | ); |
| 94 | }; |
| 95 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 96 | NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_lvalue_reference,void,false) |
| 97 | #ifndef NDNBOOST_NO_CV_VOID_SPECIALIZATIONS |
| 98 | NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_lvalue_reference,void const,false) |
| 99 | NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_lvalue_reference,void volatile,false) |
| 100 | NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_lvalue_reference,void const volatile,false) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 101 | #endif |
| 102 | |
| 103 | } // namespace detail |
| 104 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 105 | NDNBOOST_TT_AUX_BOOL_TRAIT_DEF1(is_lvalue_reference,T,::ndnboost::detail::is_lvalue_reference_impl<T>::value) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 106 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 107 | #ifdef NDNBOOST_MSVC |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 108 | # pragma warning(pop) |
| 109 | #endif |
| 110 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 111 | #endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 112 | |
| 113 | } // namespace ndnboost |
| 114 | |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 115 | #include <ndnboost/type_traits/detail/bool_trait_undef.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 116 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 117 | #endif // NDNBOOST_TT_IS_REFERENCE_HPP_INCLUDED |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 118 | |