-
Notifications
You must be signed in to change notification settings - Fork 1
/
rank.hpp
28 lines (22 loc) · 798 Bytes
/
rank.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#pragma once
#include <cstddef>
namespace cu
{
/// This is a helper class which enables the prioritization of overloads.
///
/// If there are two overloads of a function that only differ in one argument
/// type, which are @c Rank<N> and @c Rang<M>, and the function is called
/// given an argument of type @c Rank<K> where @c K>=N and @c K>=M, then
/// the overload with the larger @c Rank number will be selected by the
/// compiler.
///
/// This is helpful, when an overload shall be prioritized over another and
/// the prioritized overload may be excluded from overload resolution because
/// of SFINAE (Substitution Failure Is Not An Error).
template <std::size_t N>
class Rank;
template <>
class Rank<0> {};
template <std::size_t N>
class Rank : public Rank<N-1> {};
} // namespace cu