tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
common_comparison_category.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2021 Tobias Hienzsch
3
4#ifndef TETL_COMPARE_COMMON_COMPARISON_CATEGORY_HPP
5#define TETL_COMPARE_COMMON_COMPARISON_CATEGORY_HPP
6
7#include <etl/_compare/partial_ordering.hpp>
8#include <etl/_compare/strong_ordering.hpp>
9#include <etl/_compare/weak_ordering.hpp>
10#include <etl/_type_traits/is_same.hpp>
11
12namespace etl {
13
14namespace detail {
15
16template <unsigned>
17struct common_cmpcat_base {
18 using type = void;
19};
20
21template <>
22struct common_cmpcat_base<0U> {
23 using type = strong_ordering;
24};
25
26template <>
27struct common_cmpcat_base<2U> {
28 using type = partial_ordering;
29};
30
31template <>
32struct common_cmpcat_base<4U> {
33 using type = weak_ordering;
34};
35
36template <>
37struct common_cmpcat_base<6U> {
38 using type = partial_ordering;
39};
40
41} // namespace detail
42
43/// \ingroup compare
44template <typename... Ts>
46 :
47 // clang-format off
48 detail::common_cmpcat_base<(0U | ... |
49 (is_same_v<Ts, strong_ordering> ? 0U :
50 is_same_v<Ts, weak_ordering> ? 4U :
51 is_same_v<Ts, partial_ordering> ? 2U : 1U)
52 )>
53// clang-format on
54{ };
55
56/// \relates common_comparison_category
57/// \ingroup compare
58template <typename... Ts>
59using common_comparison_category_t = typename common_comparison_category<Ts...>::type;
60
61} // namespace etl
62
63#endif // TETL_COMPARE_COMMON_COMPARISON_CATEGORY_HPP
Definition adjacent_find.hpp:9
Definition common_comparison_category.hpp:54
Definition partial_ordering.hpp:13
Definition strong_ordering.hpp:15
Definition weak_ordering.hpp:14