Expand Minimize

rank Class

Gets number of array dimensions.

template<class Ty>
    struct rank;

Ty

The type to query.

The type query holds the value of the number of dimensions of the array type Ty, or 0 if Ty is not an array type.

 

// std_tr1__type_traits__rank.cpp 
// compile with: /EHsc 
#include <type_traits> 
#include <iostream> 
 
int main() 
    { 
    std::cout << "rank<int> == " 
        << std::rank<int>::value << std::endl; 
    std::cout << "rank<int[5]> == " 
        << std::rank<int[5]>::value << std::endl; 
    std::cout << "rank<int[5][10]> == " 
        << std::rank<int[5][10]>::value << std::endl; 
 
    return (0); 
    } 
 
rank<int> == 0
rank<int[5]> == 1
rank<int[5][10]> == 2

Header: <type_traits>

Namespace: std

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft