Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
arene::base::priority_tag< N > Class Template Reference

A priority tag for overload resolution. More...

Detailed Description

template<std::size_t N>
class arene::base::priority_tag< N >

A priority tag for overload resolution.

Template Parameters
NThe priority level.

The priority tag gives an easy to reason about method of controlling the function overload resolution order. It creates an inheritance hierarchy based on the integer given, and overload resultion will rank potential overloads based on the depth of the inheritance hierarchy.

// Exact match, first overload tried
template<class T>
auto test(T t, priority_tag<2>) -> decltype(swap(t, t), std::true_type{});
// Conversion to parent class, second overload tried
template<class T>
auto test(T t, priority_tag<1>) -> decltype((t).swap(t), std::true_type{});
// Conversion to parent-of-parent class, third overload tried
template<class T>
auto test(T t, priority_tag<0>) -> std::false_type;
template<class T>
using has_swap = decltype(test(T{}, priority_tag<2>{}));
A priority tag for overload resolution.
Definition priority_tag.hpp:43
static ARENE_MAYBE_UNUSED constexpr auto const & swap
A Customization Point Object implementation of the constexpr compatible std::swap from C++17.
Definition swap.hpp:136
bool_constant< false > false_type
An alias for bool_constant<false>
Definition integral_constant.hpp:79
bool_constant< true > true_type
An alias for bool_constant<true>
Definition integral_constant.hpp:76

The documentation for this class was generated from the following file: