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
17namespace boost {
18
19namespace 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
30template <class T, std::size_t N>
31struct extent_imp
32{
33 BOOST_STATIC_CONSTANT(std::size_t, value = 0);
34};
35#if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
36template <class T, std::size_t R, std::size_t N>
37struct extent_imp<T[R], N>
38{
39 BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value));
40};
41
42template <class T, std::size_t R, std::size_t N>
43struct 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
48template <class T, std::size_t R, std::size_t N>
49struct 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
54template <class T, std::size_t R, std::size_t N>
55struct 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
60template <class T, std::size_t R>
61struct extent_imp<T[R],0>
62{
63 BOOST_STATIC_CONSTANT(std::size_t, value = R);
64};
65
66template <class T, std::size_t R>
67struct extent_imp<T const[R], 0>
68{
69 BOOST_STATIC_CONSTANT(std::size_t, value = R);
70};
71
72template <class T, std::size_t R>
73struct extent_imp<T volatile[R], 0>
74{
75 BOOST_STATIC_CONSTANT(std::size_t, value = R);
76};
77
78template <class T, std::size_t R>
79struct 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__)
85template <class T, std::size_t N>
86struct extent_imp<T[], N>
87{
88 BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value));
89};
90template <class T, std::size_t N>
91struct extent_imp<T const[], N>
92{
93 BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value));
94};
95template <class T, std::size_t N>
96struct extent_imp<T volatile[], N>
97{
98 BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value));
99};
100template <class T, std::size_t N>
101struct extent_imp<T const volatile[], N>
102{
103 BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp<T, N-1>::value));
104};
105template <class T>
106struct extent_imp<T[], 0>
107{
108 BOOST_STATIC_CONSTANT(std::size_t, value = 0);
109};
110template <class T>
111struct extent_imp<T const[], 0>
112{
113 BOOST_STATIC_CONSTANT(std::size_t, value = 0);
114};
115template <class T>
116struct extent_imp<T volatile[], 0>
117{
118 BOOST_STATIC_CONSTANT(std::size_t, value = 0);
119};
120template <class T>
121struct 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
131template <class T, std::size_t N = 0>
132struct 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

source code of include/boost/type_traits/extent.hpp