Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | |
| 2 | // (C) Copyright John Maddock 2005. |
| 3 | // Use, modification and distribution are subject to the Boost Software License, |
| 4 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
| 5 | // http://www.boost.org/LICENSE_1_0.txt). |
| 6 | // |
| 7 | // See http://www.boost.org/libs/type_traits for most recent version including documentation. |
| 8 | |
| 9 | |
| 10 | #ifndef BOOST_TT_EXTENT_HPP_INCLUDED |
| 11 | #define BOOST_TT_EXTENT_HPP_INCLUDED |
| 12 | |
| 13 | // should be the last #include |
| 14 | #include <ndnboost/type_traits/detail/size_t_trait_def.hpp> |
| 15 | |
| 16 | namespace ndnboost { |
| 17 | |
| 18 | namespace detail{ |
| 19 | |
| 20 | #if defined( __CODEGEARC__ ) |
| 21 | // wrap the impl as main trait provides additional MPL lambda support |
| 22 | template < typename T, std::size_t N > |
| 23 | struct extent_imp { |
| 24 | static const std::size_t value = __array_extent(T, N); |
| 25 | }; |
| 26 | |
| 27 | #else |
| 28 | |
| 29 | template <class T, std::size_t N> |
| 30 | struct extent_imp |
| 31 | { |
| 32 | BOOST_STATIC_CONSTANT(std::size_t, value = 0); |
| 33 | }; |
| 34 | #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS) |
| 35 | template <class T, std::size_t R, std::size_t N> |
| 36 | struct extent_imp<T[R], N> |
| 37 | { |
| 38 | BOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value)); |
| 39 | }; |
| 40 | |
| 41 | template <class T, std::size_t R, std::size_t N> |
| 42 | struct extent_imp<T const[R], N> |
| 43 | { |
| 44 | BOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value)); |
| 45 | }; |
| 46 | |
| 47 | template <class T, std::size_t R, std::size_t N> |
| 48 | struct extent_imp<T volatile[R], N> |
| 49 | { |
| 50 | BOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value)); |
| 51 | }; |
| 52 | |
| 53 | template <class T, std::size_t R, std::size_t N> |
| 54 | struct extent_imp<T const volatile[R], N> |
| 55 | { |
| 56 | BOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value)); |
| 57 | }; |
| 58 | |
| 59 | template <class T, std::size_t R> |
| 60 | struct extent_imp<T[R],0> |
| 61 | { |
| 62 | BOOST_STATIC_CONSTANT(std::size_t, value = R); |
| 63 | }; |
| 64 | |
| 65 | template <class T, std::size_t R> |
| 66 | struct extent_imp<T const[R], 0> |
| 67 | { |
| 68 | BOOST_STATIC_CONSTANT(std::size_t, value = R); |
| 69 | }; |
| 70 | |
| 71 | template <class T, std::size_t R> |
| 72 | struct extent_imp<T volatile[R], 0> |
| 73 | { |
| 74 | BOOST_STATIC_CONSTANT(std::size_t, value = R); |
| 75 | }; |
| 76 | |
| 77 | template <class T, std::size_t R> |
| 78 | struct extent_imp<T const volatile[R], 0> |
| 79 | { |
| 80 | BOOST_STATIC_CONSTANT(std::size_t, value = R); |
| 81 | }; |
| 82 | |
| 83 | #if !BOOST_WORKAROUND(__BORLANDC__, < 0x600) && !defined(__IBMCPP__) && !BOOST_WORKAROUND(__DMC__, BOOST_TESTED_AT(0x840)) && !defined(__MWERKS__) |
| 84 | template <class T, std::size_t N> |
| 85 | struct extent_imp<T[], N> |
| 86 | { |
| 87 | BOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value)); |
| 88 | }; |
| 89 | template <class T, std::size_t N> |
| 90 | struct extent_imp<T const[], N> |
| 91 | { |
| 92 | BOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value)); |
| 93 | }; |
| 94 | template <class T, std::size_t N> |
| 95 | struct extent_imp<T volatile[], N> |
| 96 | { |
| 97 | BOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value)); |
| 98 | }; |
| 99 | template <class T, std::size_t N> |
| 100 | struct extent_imp<T const volatile[], N> |
| 101 | { |
| 102 | BOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value)); |
| 103 | }; |
| 104 | template <class T> |
| 105 | struct extent_imp<T[], 0> |
| 106 | { |
| 107 | BOOST_STATIC_CONSTANT(std::size_t, value = 0); |
| 108 | }; |
| 109 | template <class T> |
| 110 | struct extent_imp<T const[], 0> |
| 111 | { |
| 112 | BOOST_STATIC_CONSTANT(std::size_t, value = 0); |
| 113 | }; |
| 114 | template <class T> |
| 115 | struct extent_imp<T volatile[], 0> |
| 116 | { |
| 117 | BOOST_STATIC_CONSTANT(std::size_t, value = 0); |
| 118 | }; |
| 119 | template <class T> |
| 120 | struct extent_imp<T const volatile[], 0> |
| 121 | { |
| 122 | BOOST_STATIC_CONSTANT(std::size_t, value = 0); |
| 123 | }; |
| 124 | #endif |
| 125 | #endif |
| 126 | |
| 127 | #endif // non-CodeGear implementation |
| 128 | } // ::ndnboost::detail |
| 129 | |
| 130 | template <class T, std::size_t N = 0> |
| 131 | struct extent |
| 132 | : public ::ndnboost::integral_constant<std::size_t, ::ndnboost::detail::extent_imp<T,N>::value> |
| 133 | { |
| 134 | #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) |
| 135 | typedef ::ndnboost::integral_constant<std::size_t, ::ndnboost::detail::extent_imp<T,N>::value> base_; |
| 136 | using base_::value; |
| 137 | #endif |
| 138 | BOOST_MPL_AUX_LAMBDA_SUPPORT(1,extent,(T)) |
| 139 | }; |
| 140 | |
| 141 | } // namespace ndnboost |
| 142 | |
| 143 | #include <ndnboost/type_traits/detail/size_t_trait_undef.hpp> |
| 144 | |
| 145 | #endif // BOOST_TT_IS_MEMBER_FUNCTION_POINTER_HPP_INCLUDED |