Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 1 | |
| 2 | // (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes, Howard |
| 3 | // Hinnant & John Maddock 2000. |
| 4 | // Use, modification and distribution are subject to the Boost Software License, |
| 5 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
| 6 | // http://www.boost.org/LICENSE_1_0.txt). |
| 7 | // |
| 8 | // See http://www.boost.org/libs/type_traits for most recent version including documentation. |
| 9 | |
| 10 | |
| 11 | // Some fixes for is_array are based on a newsgroup posting by Jonathan Lundquist. |
| 12 | |
| 13 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 14 | #ifndef NDNBOOST_TT_IS_ARRAY_HPP_INCLUDED |
| 15 | #define NDNBOOST_TT_IS_ARRAY_HPP_INCLUDED |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 16 | |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 17 | #include <ndnboost/type_traits/config.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 18 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 19 | #ifdef NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 20 | # include <ndnboost/type_traits/detail/yes_no_type.hpp> |
| 21 | # include <ndnboost/type_traits/detail/wrap.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 22 | #endif |
| 23 | |
| 24 | #include <cstddef> |
| 25 | |
| 26 | // should be the last #include |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 27 | #include <ndnboost/type_traits/detail/bool_trait_def.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 28 | |
| 29 | namespace ndnboost { |
| 30 | |
| 31 | #if defined( __CODEGEARC__ ) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 32 | NDNBOOST_TT_AUX_BOOL_TRAIT_DEF1(is_array,T,__is_array(T)) |
| 33 | #elif !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
| 34 | NDNBOOST_TT_AUX_BOOL_TRAIT_DEF1(is_array,T,false) |
| 35 | #if !defined(NDNBOOST_NO_ARRAY_TYPE_SPECIALIZATIONS) |
| 36 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,std::size_t N,is_array,T[N],true) |
| 37 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,std::size_t N,is_array,T const[N],true) |
| 38 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,std::size_t N,is_array,T volatile[N],true) |
| 39 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,std::size_t N,is_array,T const volatile[N],true) |
| 40 | #if !NDNBOOST_WORKAROUND(__BORLANDC__, < 0x600) && !defined(__IBMCPP__) && !NDNBOOST_WORKAROUND(__DMC__, NDNBOOST_TESTED_AT(0x840)) |
| 41 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_array,T[],true) |
| 42 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_array,T const[],true) |
| 43 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_array,T volatile[],true) |
| 44 | NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_array,T const volatile[],true) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 45 | #endif |
| 46 | #endif |
| 47 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 48 | #else // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 49 | |
| 50 | namespace detail { |
| 51 | |
| 52 | using ::ndnboost::type_traits::yes_type; |
| 53 | using ::ndnboost::type_traits::no_type; |
| 54 | using ::ndnboost::type_traits::wrap; |
| 55 | |
| 56 | template< typename T > T(* is_array_tester1(wrap<T>) )(wrap<T>); |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 57 | char NDNBOOST_TT_DECL is_array_tester1(...); |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 58 | |
| 59 | template< typename T> no_type is_array_tester2(T(*)(wrap<T>)); |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 60 | yes_type NDNBOOST_TT_DECL is_array_tester2(...); |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 61 | |
| 62 | template< typename T > |
| 63 | struct is_array_impl |
| 64 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 65 | NDNBOOST_STATIC_CONSTANT(bool, value = |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 66 | sizeof(::ndnboost::detail::is_array_tester2( |
| 67 | ::ndnboost::detail::is_array_tester1( |
| 68 | ::ndnboost::type_traits::wrap<T>() |
| 69 | ) |
| 70 | )) == 1 |
| 71 | ); |
| 72 | }; |
| 73 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 74 | #ifndef NDNBOOST_NO_CV_VOID_SPECIALIZATIONS |
| 75 | NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_array,void,false) |
| 76 | NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_array,void const,false) |
| 77 | NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_array,void volatile,false) |
| 78 | NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_array,void const volatile,false) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 79 | #endif |
| 80 | |
| 81 | } // namespace detail |
| 82 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 83 | NDNBOOST_TT_AUX_BOOL_TRAIT_DEF1(is_array,T,::ndnboost::detail::is_array_impl<T>::value) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 84 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 85 | #endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 86 | |
| 87 | } // namespace ndnboost |
| 88 | |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 89 | #include <ndnboost/type_traits/detail/bool_trait_undef.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 90 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 91 | #endif // NDNBOOST_TT_IS_ARRAY_HPP_INCLUDED |