Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
priority_tag.hpp
Go to the documentation of this file.
1
// Copyright 2026, Toyota Motor Corporation
2
//
3
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5
#
ifndef
INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_PRIORITY_TAG_HPP_
6
#
define
INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_PRIORITY_TAG_HPP_
7
8
#
include
"arene/base/stdlib_choice/cstddef.hpp"
// IWYU pragma: keep
9
10
// parasoft-begin-suppress AUTOSAR-A2_7_3-a "False positive: Everything is preceeded by a comment with @brief"
11
12
namespace
arene
{
13
namespace
base
{
14
15
// parasoft-begin-suppress AUTOSAR-A2_7_2-a "False positive: No code is commented out, an example is included in the
16
// docstring"
17
18
/// @brief A priority tag for overload resolution.
19
/// @tparam N The priority level.
20
///
21
/// The priority tag gives an easy to reason about method of controlling the function overload resolution order. It
22
/// creates an inheritance hierarchy based on the integer given, and overload resultion will rank potential overloads
23
/// based on the depth of the inheritance hierarchy.
24
///
25
/// ~~~{.cpp}
26
/// // Exact match, first overload tried
27
/// template<class T>
28
/// auto test(T t, priority_tag<2>) -> decltype(swap(t, t), std::true_type{});
29
///
30
/// // Conversion to parent class, second overload tried
31
/// template<class T>
32
/// auto test(T t, priority_tag<1>) -> decltype((t).swap(t), std::true_type{});
33
///
34
/// // Conversion to parent-of-parent class, third overload tried
35
/// template<class T>
36
/// auto test(T t, priority_tag<0>) -> std::false_type;
37
///
38
/// template<class T>
39
/// using has_swap = decltype(test(T{}, priority_tag<2>{}));
40
/// ~~~
41
///
42
template
<std::size_t N>
43
class
priority_tag
:
public
priority_tag
<
N
-
std
::
size_t
{1}> {};
44
45
// parasoft-end-suppress AUTOSAR-A2_7_2-a "False positive: No code is commented out, an example is included in the
46
// docstring"
47
48
/// @brief A priority tag for overload resolution.
49
/// @tparam N The priority level.
50
///
51
/// The base priority_tag which ends the inheritance hierarchy.
52
template
<>
53
class
priority_tag
<
std
::
size_t
{0}> {};
54
/// @}
55
56
}
// namespace base
57
}
// namespace arene
58
59
#
endif
// INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_PRIORITY_TAG_HPP_
arene::base::priority_tag
A priority tag for overload resolution.
Definition
priority_tag.hpp:43
arene::base
Definition
array_exceptions_disabled.cpp:11
arene
Copyright 2026, Toyota Motor Corporation.
Definition
array_exceptions_disabled.cpp:10
arene
base
type_traits
priority_tag.hpp
Generated by
1.13.2