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 <boost/type_traits/integral_constant.hpp>
14#include <boost/detail/workaround.hpp>
15
16namespace boost {
17
18namespace 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
29template <class T, std::size_t N>
30struct extent_imp
31{
32 BOOST_STATIC_CONSTANT(std::size_t, value = 0);
33};
34#if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
35template <class T, std::size_t R, std::size_t N>
36struct extent_imp<T[R], N>
37{
38 BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value));
39};
40
41template <class T, std::size_t R, std::size_t N>
42struct extent_imp<T const[R], N>
43{
44 BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value));
45};
46
47template <class T, std::size_t R, std::size_t N>
48struct extent_imp<T volatile[R], N>
49{
50 BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value));
51};
52
53template <class T, std::size_t R, std::size_t N>
54struct extent_imp<T const volatile[R], N>
55{
56 BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value));
57};
58
59template <class T, std::size_t R>
60struct extent_imp<T[R],0>
61{
62 BOOST_STATIC_CONSTANT(std::size_t, value = R);
63};
64
65template <class T, std::size_t R>
66struct extent_imp<T const[R], 0>
67{
68 BOOST_STATIC_CONSTANT(std::size_t, value = R);
69};
70
71template <class T, std::size_t R>
72struct extent_imp<T volatile[R], 0>
73{
74 BOOST_STATIC_CONSTANT(std::size_t, value = R);
75};
76
77template <class T, std::size_t R>
78struct 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__)
84template <class T, std::size_t N>
85struct extent_imp<T[], N>
86{
87 BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value));
88};
89template <class T, std::size_t N>
90struct extent_imp<T const[], N>
91{
92 BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value));
93};
94template <class T, std::size_t N>
95struct extent_imp<T volatile[], N>
96{
97 BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value));
98};
99template <class T, std::size_t N>
100struct extent_imp<T const volatile[], N>
101{
102 BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value));
103};
104template <class T>
105struct extent_imp<T[], 0>
106{
107 BOOST_STATIC_CONSTANT(std::size_t, value = 0);
108};
109template <class T>
110struct extent_imp<T const[], 0>
111{
112 BOOST_STATIC_CONSTANT(std::size_t, value = 0);
113};
114template <class T>
115struct extent_imp<T volatile[], 0>
116{
117 BOOST_STATIC_CONSTANT(std::size_t, value = 0);
118};
119template <class T>
120struct 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} // ::boost::detail
129
130template <class T, std::size_t N = 0>
131struct extent
132 : public ::boost::integral_constant<std::size_t, ::boost::detail::extent_imp<T,N>::value>
133{
134};
135
136} // namespace boost
137
138#endif // BOOST_TT_IS_MEMBER_FUNCTION_POINTER_HPP_INCLUDED
139