頭檔案中存在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