blob: 51d3571423bda7dde361faf771f146b3bfc033eb [file] [log] [blame]
Jeff Thompsonf7d49942013-08-01 16:47:40 -07001
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
14#ifndef BOOST_TT_IS_ARRAY_HPP_INCLUDED
15#define BOOST_TT_IS_ARRAY_HPP_INCLUDED
16
Jeff Thompson2277ce52013-08-01 17:34:11 -070017#include <ndnboost/type_traits/config.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070018
19#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Jeff Thompson2277ce52013-08-01 17:34:11 -070020# include <ndnboost/type_traits/detail/yes_no_type.hpp>
21# include <ndnboost/type_traits/detail/wrap.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070022#endif
23
24#include <cstddef>
25
26// should be the last #include
Jeff Thompson2277ce52013-08-01 17:34:11 -070027#include <ndnboost/type_traits/detail/bool_trait_def.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070028
29namespace ndnboost {
30
31#if defined( __CODEGEARC__ )
32BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_array,T,__is_array(T))
33#elif !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
34BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_array,T,false)
35#if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
36BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,std::size_t N,is_array,T[N],true)
37BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,std::size_t N,is_array,T const[N],true)
38BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,std::size_t N,is_array,T volatile[N],true)
39BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,std::size_t N,is_array,T const volatile[N],true)
40#if !BOOST_WORKAROUND(__BORLANDC__, < 0x600) && !defined(__IBMCPP__) && !BOOST_WORKAROUND(__DMC__, BOOST_TESTED_AT(0x840))
41BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_array,T[],true)
42BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_array,T const[],true)
43BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_array,T volatile[],true)
44BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_array,T const volatile[],true)
45#endif
46#endif
47
48#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
49
50namespace detail {
51
52using ::ndnboost::type_traits::yes_type;
53using ::ndnboost::type_traits::no_type;
54using ::ndnboost::type_traits::wrap;
55
56template< typename T > T(* is_array_tester1(wrap<T>) )(wrap<T>);
57char BOOST_TT_DECL is_array_tester1(...);
58
59template< typename T> no_type is_array_tester2(T(*)(wrap<T>));
60yes_type BOOST_TT_DECL is_array_tester2(...);
61
62template< typename T >
63struct is_array_impl
64{
65 BOOST_STATIC_CONSTANT(bool, value =
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
74#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
75BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_array,void,false)
76BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_array,void const,false)
77BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_array,void volatile,false)
78BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_array,void const volatile,false)
79#endif
80
81} // namespace detail
82
83BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_array,T,::ndnboost::detail::is_array_impl<T>::value)
84
85#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
86
87} // namespace ndnboost
88
Jeff Thompson2277ce52013-08-01 17:34:11 -070089#include <ndnboost/type_traits/detail/bool_trait_undef.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070090
91#endif // BOOST_TT_IS_ARRAY_HPP_INCLUDED