Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
is_base_quantity_kind.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#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_UNITS_IS_BASE_QUANTITY_KIND_HPP_
5#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_UNITS_IS_BASE_QUANTITY_KIND_HPP_
6
7#include "arene/base/constraints/constraints.hpp"
8#include "arene/base/stdlib_choice/enable_if.hpp"
9#include "arene/base/stdlib_choice/is_same.hpp"
10#include "arene/base/units/is_quantity_kind.hpp"
11
12namespace arene {
13namespace base {
14
15namespace is_base_quantity_kind_detail {
16/// @brief Type trait for checking if one type is a base quantity kind for another. Evaluates to @c true if the first
17/// type is a base quantity kind of the second (the second is a derived quantity kind of the first), @c false otherwise
18/// @tparam BaseKind the base kind
19/// @tparam Type the type to check.
20template <typename BaseKind, typename Type, typename = constraints<>>
21extern constexpr bool is_base_quantity_kind_of_v = false;
22
23/// @brief Type trait for checking if one type is a base quantity kind for another. Evaluates to @c true if the first
24/// type is a base quantity kind of the second (the second is a derived quantity kind of the first), @c false otherwise
25/// @tparam BaseKind the base kind
26/// @tparam Type the type to check.
27template <typename BaseKind, typename Type>
28extern constexpr bool is_base_quantity_kind_of_v<
29 BaseKind,
30 Type,
31 constraints<
32 std::enable_if_t<is_quantity_kind_v<BaseKind>>,
33 std::enable_if_t<is_quantity_kind_v<Type>>,
34 std::enable_if_t<std::is_same<typename Type::parent_quantity_kind_type, BaseKind>::value>>> = true;
35
36/// @brief Type trait for checking if one type is a base quantity kind for another. Evaluates to @c true if the first
37/// type is a base quantity kind of the second (the second is a derived quantity kind of the first), @c false otherwise
38/// @tparam BaseKind the base kind
39/// @tparam Type the type to check.
40template <typename BaseKind, typename Type>
41extern constexpr bool is_base_quantity_kind_of_v<
42 BaseKind,
43 Type,
44 constraints<
45 std::enable_if_t<is_quantity_kind_v<BaseKind>>,
46 std::enable_if_t<is_quantity_kind_v<Type>>,
47 std::enable_if_t<!std::is_same<typename Type::parent_quantity_kind_type, BaseKind>::value>,
48 std::enable_if_t<is_base_quantity_kind_of_v<BaseKind, typename Type::parent_quantity_kind_type>>>> = true;
49
50} // namespace is_base_quantity_kind_detail
51
52/// @brief Type trait for checking if one type is a base quantity kind for another. Evaluates to @c true if the first
53/// type is a base quantity kind of the second (the second is a derived quantity kind of the first), @c false otherwise
54///
55/// Note: a quantity kind is not considered to be a base quantity for itself, so @c is_base_quantity_kind_of_v<T,T> will
56/// always be @c false, for all types @c T
57///
58/// @tparam BaseKind the base kind
59/// @tparam Type the type to check.
60template <typename BaseKind, typename Type>
61extern constexpr bool is_base_quantity_kind_of_v =
63
64/// @brief Type trait for checking if one type is a base quantity kind for another, or the same type. Evaluates to @c
65/// true if the first type is the same as the second, or a base quantity kind of the second (the second is a derived
66/// quantity kind of the first), @c false otherwise
67///
68/// @tparam BaseKind the base kind
69/// @tparam Type the type to check.
70template <typename BaseKind, typename Type>
71extern constexpr bool is_base_quantity_kind_of_or_same_as_v =
72 is_base_quantity_kind_of_v<BaseKind, Type> || std::is_same<BaseKind, Type>::value;
73
74} // namespace base
75} // namespace arene
76
77#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_UNITS_IS_BASE_QUANTITY_KIND_HPP_
Definition array_exceptions_disabled.cpp:11
constexpr bool is_base_quantity_kind_of_v
Type trait for checking if one type is a base quantity kind for another. Evaluates to true if the fir...
constexpr bool is_base_quantity_kind_of_or_same_as_v
Type trait for checking if one type is a base quantity kind for another, or the same type....
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10