Rank (computer programming): Difference between revisions

Content deleted Content added
Reformat code, add rank_v and fix rankof
m Task 70: Update syntaxhighlight tags - remove use of deprecated <source> tags
Line 7:
The box below instead shows how ''rank of a type'' and ''rank of an array expression'' could be defined (in a semi-formal style) for C++ and illustrates a simple way to calculate them at compile time.
 
<sourcesyntaxhighlight lang="cpp">
#include <type_traits>
#include <cstddef>
Line 44:
return rank_v<unqualified_t<T>>;
}
</syntaxhighlight>
</source>
Given the code above the rank of a type T can be calculated at compile time by
:<sourcesyntaxhighlight lang="cpp">rank<T>::value</sourcesyntaxhighlight>
or the shorter form
 
:<sourcesyntaxhighlight lang="cpp">rank_v<T></sourcesyntaxhighlight>
 
Calculating the rank of an expression can be done using
:<sourcesyntaxhighlight lang="cpp">rankof(expr)</sourcesyntaxhighlight>
 
==See also==