Difference between revisions of "cpp/types/extent"
From cppreference.com
m (size_t for consistency (also used in gcc and libc++)) |
(simplify the example) |
||
Line 38: | Line 38: | ||
#include <iostream> | #include <iostream> | ||
#include <type_traits> | #include <type_traits> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
int main() | int main() | ||
{ | { | ||
− | int | + | std::cout << std::extent<int[3]>::value << '\n'; |
− | + | std::cout << std::extent<int[3][4]>::value << '\n'; | |
− | + | std::cout << std::extent<int[3][4],1>::value << '\n'; | |
− | int | + | std::cout << std::extent<int[3][4],2>::value << '\n'; |
− | + | std::cout << std::extent<int[]>::value << '\n'; | |
} | } | ||
| output= | | output= | ||
− | 4 | + | 3 |
+ | 3 | ||
+ | 4 | ||
+ | 0 | ||
+ | 0 | ||
}} | }} | ||
Revision as of 11:02, 26 October 2011
Template:cpp/types/sidebar Template:ddcl list begin <tr class="t-dsc-header">
<td>Defined in header
</td>
<type_traits>
<td></td> <td></td> </tr> <tr class="t-dcl ">
<td >template< class T, unsigned N = 0>
struct extent;
</td>
struct extent;
<td class="t-dcl-nopad"> </td> <td > Template:mark c++11 feature </td> </tr> Template:ddcl list end
If T
is an array type, provides the member constant value
equal to the number of elements along the N
th dimension of the array, if N
is in [0, std::rank<T>::value)
. For any other type, or if T
is array of unknown bound along its first dimension and N
is 0, value
is 0.
Contents |
Inherited from std::integral_constant
Member constants
value [static] |
the number of elements along the N th dimension of T (public static member constant) |
Member functions
operator std::size_t |
converts the object to std::size_t, returns value (public member function) |
operator() (C++14) |
returns value (public member function) |
Member types
Type | Definition |
value_type
|
std::size_t |
type
|
std::integral_constant<std::size_t, value> |
Equivalent definition
Example
See also
(C++11) |
checks if a type is an array type (class template) |
(C++11) |
obtains the number of dimensions of an array type (class template) |
(C++11) |
removes one extent from the given array type (class template) |
(C++11) |
removes all extents from the given array type (class template) |