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_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_MEMBER_POINTER_HPP_INCLUDED |
| 22 | #define NDNBOOST_TT_IS_MEMBER_POINTER_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> |
| 25 | #include <ndnboost/detail/workaround.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 26 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 27 | #if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !NDNBOOST_WORKAROUND(__BORLANDC__, < 0x600) |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 28 | # include <ndnboost/type_traits/is_member_function_pointer.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 29 | #else |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 30 | # include <ndnboost/type_traits/is_reference.hpp> |
| 31 | # include <ndnboost/type_traits/is_array.hpp> |
| 32 | # include <ndnboost/type_traits/detail/is_mem_fun_pointer_tester.hpp> |
| 33 | # include <ndnboost/type_traits/detail/yes_no_type.hpp> |
| 34 | # include <ndnboost/type_traits/detail/false_result.hpp> |
| 35 | # include <ndnboost/type_traits/detail/ice_or.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 36 | #endif |
| 37 | |
| 38 | // should be the last #include |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 39 | #include <ndnboost/type_traits/detail/bool_trait_def.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 40 | |
| 41 | namespace ndnboost { |
| 42 | |
| 43 | #if defined( __CODEGEARC__ ) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 44 | NDNBOOST_TT_AUX_BOOL_TRAIT_DEF1(is_member_pointer,T,__is_member_pointer(T)) |
| 45 | #elif NDNBOOST_WORKAROUND(__BORLANDC__, < 0x600) |
| 46 | NDNBOOST_TT_AUX_BOOL_TRAIT_DEF1(is_member_pointer,T,false) |
| 47 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,typename U,is_member_pointer,U T::*,true) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 48 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 49 | #elif !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
| 50 | NDNBOOST_TT_AUX_BOOL_TRAIT_DEF1(is_member_pointer,T,::ndnboost::is_member_function_pointer<T>::value) |
| 51 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,typename U,is_member_pointer,U T::*,true) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 52 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 53 | #if !NDNBOOST_WORKAROUND(__MWERKS__,<=0x3003) && !NDNBOOST_WORKAROUND(__IBMCPP__, <=600) |
| 54 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,typename U,is_member_pointer,U T::*const,true) |
| 55 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,typename U,is_member_pointer,U T::*volatile,true) |
| 56 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,typename U,is_member_pointer,U T::*const volatile,true) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 57 | #endif |
| 58 | |
| 59 | #else // no partial template specialization |
| 60 | |
| 61 | namespace detail { |
| 62 | |
| 63 | template <typename R, typename T> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 64 | ::ndnboost::type_traits::yes_type NDNBOOST_TT_DECL is_member_pointer_tester(R T::*const volatile*); |
| 65 | ::ndnboost::type_traits::no_type NDNBOOST_TT_DECL is_member_pointer_tester(...); |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 66 | |
| 67 | template <bool> |
| 68 | struct is_member_pointer_select |
| 69 | : public ::ndnboost::type_traits::false_result |
| 70 | { |
| 71 | }; |
| 72 | |
| 73 | template <> |
| 74 | struct is_member_pointer_select<false> |
| 75 | { |
| 76 | template <typename T> struct result_ |
| 77 | { |
| 78 | static T* make_t(); |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 79 | NDNBOOST_STATIC_CONSTANT( |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 80 | bool, value = |
| 81 | (::ndnboost::type_traits::ice_or< |
| 82 | (1 == sizeof(::ndnboost::type_traits::is_mem_fun_pointer_tester(make_t()))), |
| 83 | (1 == sizeof(is_member_pointer_tester(make_t()))) |
| 84 | >::value) ); |
| 85 | }; |
| 86 | }; |
| 87 | |
| 88 | template <typename T> |
| 89 | struct is_member_pointer_impl |
| 90 | : public is_member_pointer_select< |
| 91 | ::ndnboost::type_traits::ice_or< |
| 92 | ::ndnboost::is_reference<T>::value |
| 93 | , ::ndnboost::is_array<T>::value |
| 94 | >::value |
| 95 | >::template result_<T> |
| 96 | { |
| 97 | }; |
| 98 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 99 | NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_member_pointer,void,false) |
| 100 | #ifndef NDNBOOST_NO_CV_VOID_SPECIALIZATIONS |
| 101 | NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_member_pointer,void const,false) |
| 102 | NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_member_pointer,void volatile,false) |
| 103 | NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_member_pointer,void const volatile,false) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 104 | #endif |
| 105 | |
| 106 | } // namespace detail |
| 107 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 108 | NDNBOOST_TT_AUX_BOOL_TRAIT_DEF1(is_member_pointer,T,::ndnboost::detail::is_member_pointer_impl<T>::value) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 109 | |
| 110 | #endif // __BORLANDC__ |
| 111 | |
| 112 | } // namespace ndnboost |
| 113 | |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 114 | #include <ndnboost/type_traits/detail/bool_trait_undef.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 115 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 116 | #endif // NDNBOOST_TT_IS_MEMBER_POINTER_HPP_INCLUDED |