tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
integral_constant.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_TYPE_TRAITS_INTEGRAL_CONSTANT_HPP
5#define TETL_TYPE_TRAITS_INTEGRAL_CONSTANT_HPP
6
7namespace etl {
8
9/// \ingroup type_traits
10template <typename Type, Type Val>
12 static constexpr Type value = Val;
13 using value_type = Type;
14 using type = integral_constant<Type, Val>;
15
16 constexpr operator value_type() const noexcept
17 {
18 return value;
19 }
20
21 constexpr auto operator()() const noexcept -> value_type
22 {
23 return value;
24 }
25};
26
27/// \relates integral_constant
28/// \ingroup type_traits
29template <typename Rhs, Rhs R, typename Lhs, Lhs L>
30[[nodiscard]] constexpr auto operator+(integral_constant<Rhs, R> /*l*/, integral_constant<Lhs, L> /*r*/)
31 -> integral_constant<decltype(L + R), L + R>
32{
33 return {};
34}
35
36/// \relates integral_constant
37/// \ingroup type_traits
38template <typename Rhs, Rhs R, typename Lhs, Lhs L>
39[[nodiscard]] constexpr auto operator==(integral_constant<Rhs, R> /*l*/, integral_constant<Lhs, L> /*r*/)
40 -> integral_constant<bool, L == R>
41{
42 return {};
43}
44
45/// \relates integral_constant
46/// \ingroup type_traits
47template <typename Rhs, Rhs R, typename Lhs, Lhs L>
48[[nodiscard]] constexpr auto operator!=(integral_constant<Rhs, R> /*l*/, integral_constant<Lhs, L> /*r*/)
49 -> integral_constant<bool, L != R>
50{
51 return {};
52}
53
54} // namespace etl
55
56#endif // TETL_TYPE_TRAITS_INTEGRAL_CONSTANT_HPP
constexpr auto operator==(integral_constant< Rhs, R >, integral_constant< Lhs, L >) -> integral_constant< bool, L==R >
Definition integral_constant.hpp:39
constexpr auto operator!=(integral_constant< Rhs, R >, integral_constant< Lhs, L >) -> integral_constant< bool, L !=R >
Definition integral_constant.hpp:48
constexpr auto operator+(integral_constant< Rhs, R >, integral_constant< Lhs, L >) -> integral_constant< decltype(L+R), L+R >
Definition integral_constant.hpp:30
Definition adjacent_find.hpp:9
Definition integral_constant.hpp:11
constexpr operator value_type() const noexcept
Definition integral_constant.hpp:16
constexpr auto operator()() const noexcept -> value_type
Definition integral_constant.hpp:21
static constexpr Type value
Definition integral_constant.hpp:12