Brian Silverman | 4a2409e | 2018-08-04 23:24:02 -0700 | [diff] [blame^] | 1 | [/ |
| 2 | Copyright 2007 John Maddock. |
| 3 | Distributed under the Boost Software License, Version 1.0. |
| 4 | (See accompanying file LICENSE_1_0.txt or copy at |
| 5 | http://www.boost.org/LICENSE_1_0.txt). |
| 6 | ] |
| 7 | |
| 8 | [section:extent extent] |
| 9 | template <class T, std::size_t N = 0> |
| 10 | struct extent : public __integral_constant<std::size_t, EXTENT(T,N)> {}; |
| 11 | |
| 12 | __inherit Class template extent inherits from `__integral_constant<std::size_t, EXTENT(T,N)>`, |
| 13 | where `EXTENT(T,N)` is the number of elements in the N'th array dimension of type `T`. |
| 14 | |
| 15 | If `T` is not a (built-in) array type, or if `N > __rank<T>::value`, or if the N'th array bound |
| 16 | is incomplete, then `EXTENT(T,N)` is zero. |
| 17 | |
| 18 | __header ` #include <boost/type_traits/extent.hpp>` or ` #include <boost/type_traits.hpp>` |
| 19 | |
| 20 | __examples |
| 21 | |
| 22 | [:`extent<int[1]>` inherits from `__integral_constant<std::size_t, 1>`.] |
| 23 | |
| 24 | [:`extent<double[2][3][4], 0>::type` is the type `__integral_constant<std::size_t, 2>`.] |
| 25 | |
| 26 | [:`extent<double[2][3][4], 1>::type` is the type `__integral_constant<std::size_t, 3>`.] |
| 27 | |
| 28 | [:`extent<double[2][3][4], 2>::type` is the type `__integral_constant<std::size_t, 4>`.] |
| 29 | |
| 30 | [:`extent<int[4]>::value` is an integral constant |
| 31 | expression that evaluates to /4/.] |
| 32 | |
| 33 | [:`extent<int[][2]>::value` is an integral constant |
| 34 | expression that evaluates to /0/.] |
| 35 | |
| 36 | [:`extent<int[][2], 1>::value` is an integral constant |
| 37 | expression that evaluates to /2/.] |
| 38 | |
| 39 | [:`extent<int*>::value` is an integral constant |
| 40 | expression that evaluates to /0/.] |
| 41 | |
| 42 | [:`extent<boost::array<int, 3> >::value` is an integral constant |
| 43 | expression that evaluates to /0/: `boost::array` is a class type and [*not an array type]!] |
| 44 | |
| 45 | [:`extent<T>::value_type` is the type `std::size_t`.] |
| 46 | |
| 47 | [all_compilers] |
| 48 | |
| 49 | [endsect] |
| 50 | |