头文件中存在C++ STL的std::rank模板。 C++ STL的std::rank模板用于查找类型T的等级。此函数返回类型T的等级。
头文件:
#include
模板类别:
template
struct rank;
template
inline constexpr
std::size_t rank_v
= rank::value;
用法:
std::rank::value
参数:std::rank模板接受单个参数T(Trait类)并返回其等级。
返回值:模板std::rank返回T类型的等级。
下面是演示std::rank的程序:
程序:
// C++ program to illustrate std::rank
#include
#include
using namespace std;
// Driver Code
int main()
{
cout << "rank of following type:"
<< endl;
cout << "int:"
<< rank::value
<< endl;
cout << "int[]:"
<< rank::value
<< endl;
cout << "int[][10]:"
<< rank::value
<< endl;
cout << "int[10][10]:"
<< rank::value
<< endl;
return 0;
}
输出:
rank of following type:
int:0
int[]:1
int[][10]:2
int[10][10]:2