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 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 10 | #ifndef NDNBOOST_TT_EXTENT_HPP_INCLUDED |
| 11 | #define NDNBOOST_TT_EXTENT_HPP_INCLUDED |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 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 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 32 | NDNBOOST_STATIC_CONSTANT(std::size_t, value = 0); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 33 | }; |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 34 | #if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(NDNBOOST_NO_ARRAY_TYPE_SPECIALIZATIONS) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 35 | template <class T, std::size_t R, std::size_t N> |
| 36 | struct extent_imp<T[R], N> |
| 37 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 38 | NDNBOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value)); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | template <class T, std::size_t R, std::size_t N> |
| 42 | struct extent_imp<T const[R], N> |
| 43 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 44 | NDNBOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value)); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | template <class T, std::size_t R, std::size_t N> |
| 48 | struct extent_imp<T volatile[R], N> |
| 49 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 50 | NDNBOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value)); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | template <class T, std::size_t R, std::size_t N> |
| 54 | struct extent_imp<T const volatile[R], N> |
| 55 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 56 | NDNBOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value)); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | template <class T, std::size_t R> |
| 60 | struct extent_imp<T[R],0> |
| 61 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 62 | NDNBOOST_STATIC_CONSTANT(std::size_t, value = R); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | template <class T, std::size_t R> |
| 66 | struct extent_imp<T const[R], 0> |
| 67 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 68 | NDNBOOST_STATIC_CONSTANT(std::size_t, value = R); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | template <class T, std::size_t R> |
| 72 | struct extent_imp<T volatile[R], 0> |
| 73 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 74 | NDNBOOST_STATIC_CONSTANT(std::size_t, value = R); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | template <class T, std::size_t R> |
| 78 | struct extent_imp<T const volatile[R], 0> |
| 79 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 80 | NDNBOOST_STATIC_CONSTANT(std::size_t, value = R); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 83 | #if !NDNBOOST_WORKAROUND(__BORLANDC__, < 0x600) && !defined(__IBMCPP__) && !NDNBOOST_WORKAROUND(__DMC__, NDNBOOST_TESTED_AT(0x840)) && !defined(__MWERKS__) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 84 | template <class T, std::size_t N> |
| 85 | struct extent_imp<T[], N> |
| 86 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 87 | NDNBOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value)); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 88 | }; |
| 89 | template <class T, std::size_t N> |
| 90 | struct extent_imp<T const[], N> |
| 91 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 92 | NDNBOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value)); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 93 | }; |
| 94 | template <class T, std::size_t N> |
| 95 | struct extent_imp<T volatile[], N> |
| 96 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 97 | NDNBOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value)); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 98 | }; |
| 99 | template <class T, std::size_t N> |
| 100 | struct extent_imp<T const volatile[], N> |
| 101 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 102 | NDNBOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value)); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 103 | }; |
| 104 | template <class T> |
| 105 | struct extent_imp<T[], 0> |
| 106 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 107 | NDNBOOST_STATIC_CONSTANT(std::size_t, value = 0); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 108 | }; |
| 109 | template <class T> |
| 110 | struct extent_imp<T const[], 0> |
| 111 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 112 | NDNBOOST_STATIC_CONSTANT(std::size_t, value = 0); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 113 | }; |
| 114 | template <class T> |
| 115 | struct extent_imp<T volatile[], 0> |
| 116 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 117 | NDNBOOST_STATIC_CONSTANT(std::size_t, value = 0); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 118 | }; |
| 119 | template <class T> |
| 120 | struct extent_imp<T const volatile[], 0> |
| 121 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 122 | NDNBOOST_STATIC_CONSTANT(std::size_t, value = 0); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 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 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 134 | #if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1300) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 135 | typedef ::ndnboost::integral_constant<std::size_t, ::ndnboost::detail::extent_imp<T,N>::value> base_; |
| 136 | using base_::value; |
| 137 | #endif |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 138 | NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(1,extent,(T)) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 139 | }; |
| 140 | |
| 141 | } // namespace ndnboost |
| 142 | |
| 143 | #include <ndnboost/type_traits/detail/size_t_trait_undef.hpp> |
| 144 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 145 | #endif // NDNBOOST_TT_IS_MEMBER_FUNCTION_POINTER_HPP_INCLUDED |