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 | #include <cstddef> // size_t |
14 | #include <boost/type_traits/integral_constant.hpp> |
15 | #include <boost/detail/workaround.hpp> |
16 | |
17 | namespace boost { |
18 | |
19 | namespace detail{ |
20 | |
21 | #if defined( BOOST_CODEGEARC ) |
22 | // wrap the impl as main trait provides additional MPL lambda support |
23 | template < typename T, std::size_t N > |
24 | struct extent_imp { |
25 | static const std::size_t value = __array_extent(T, N); |
26 | }; |
27 | |
28 | #else |
29 | |
30 | template <class T, std::size_t N> |
31 | struct extent_imp |
32 | { |
33 | BOOST_STATIC_CONSTANT(std::size_t, value = 0); |
34 | }; |
35 | #if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS) |
36 | template <class T, std::size_t R, std::size_t N> |
37 | struct extent_imp<T[R], N> |
38 | { |
39 | BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value)); |
40 | }; |
41 | |
42 | template <class T, std::size_t R, std::size_t N> |
43 | struct extent_imp<T const[R], N> |
44 | { |
45 | BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value)); |
46 | }; |
47 | |
48 | template <class T, std::size_t R, std::size_t N> |
49 | struct extent_imp<T volatile[R], N> |
50 | { |
51 | BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value)); |
52 | }; |
53 | |
54 | template <class T, std::size_t R, std::size_t N> |
55 | struct extent_imp<T const volatile[R], N> |
56 | { |
57 | BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value)); |
58 | }; |
59 | |
60 | template <class T, std::size_t R> |
61 | struct extent_imp<T[R],0> |
62 | { |
63 | BOOST_STATIC_CONSTANT(std::size_t, value = R); |
64 | }; |
65 | |
66 | template <class T, std::size_t R> |
67 | struct extent_imp<T const[R], 0> |
68 | { |
69 | BOOST_STATIC_CONSTANT(std::size_t, value = R); |
70 | }; |
71 | |
72 | template <class T, std::size_t R> |
73 | struct extent_imp<T volatile[R], 0> |
74 | { |
75 | BOOST_STATIC_CONSTANT(std::size_t, value = R); |
76 | }; |
77 | |
78 | template <class T, std::size_t R> |
79 | struct extent_imp<T const volatile[R], 0> |
80 | { |
81 | BOOST_STATIC_CONSTANT(std::size_t, value = R); |
82 | }; |
83 | |
84 | #if !BOOST_WORKAROUND(BOOST_BORLANDC, < 0x600) && !defined(__IBMCPP__) && !BOOST_WORKAROUND(__DMC__, BOOST_TESTED_AT(0x840)) && !defined(__MWERKS__) |
85 | template <class T, std::size_t N> |
86 | struct extent_imp<T[], N> |
87 | { |
88 | BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value)); |
89 | }; |
90 | template <class T, std::size_t N> |
91 | struct extent_imp<T const[], N> |
92 | { |
93 | BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value)); |
94 | }; |
95 | template <class T, std::size_t N> |
96 | struct extent_imp<T volatile[], N> |
97 | { |
98 | BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value)); |
99 | }; |
100 | template <class T, std::size_t N> |
101 | struct extent_imp<T const volatile[], N> |
102 | { |
103 | BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value)); |
104 | }; |
105 | template <class T> |
106 | struct extent_imp<T[], 0> |
107 | { |
108 | BOOST_STATIC_CONSTANT(std::size_t, value = 0); |
109 | }; |
110 | template <class T> |
111 | struct extent_imp<T const[], 0> |
112 | { |
113 | BOOST_STATIC_CONSTANT(std::size_t, value = 0); |
114 | }; |
115 | template <class T> |
116 | struct extent_imp<T volatile[], 0> |
117 | { |
118 | BOOST_STATIC_CONSTANT(std::size_t, value = 0); |
119 | }; |
120 | template <class T> |
121 | struct extent_imp<T const volatile[], 0> |
122 | { |
123 | BOOST_STATIC_CONSTANT(std::size_t, value = 0); |
124 | }; |
125 | #endif |
126 | #endif |
127 | |
128 | #endif // non-CodeGear implementation |
129 | } // ::boost::detail |
130 | |
131 | template <class T, std::size_t N = 0> |
132 | struct extent |
133 | : public ::boost::integral_constant<std::size_t, ::boost::detail::extent_imp<T,N>::value> |
134 | { |
135 | }; |
136 | |
137 | } // namespace boost |
138 | |
139 | #endif // BOOST_TT_IS_MEMBER_FUNCTION_POINTER_HPP_INCLUDED |
140 | |