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
9template <typename Type, Type Val>
11 static constexpr Type value = Val;
12 using value_type = Type;
13 using type = integral_constant<Type, Val>;
14
15 constexpr operator value_type() const noexcept
16 {
17 return value;
18 }
19
20 constexpr auto operator()() const noexcept -> value_type
21 {
22 return value;
23 }
24};
25
26template <typename Rhs, Rhs R, typename Lhs, Lhs L>
27[[nodiscard]] constexpr auto operator+(integral_constant<Rhs, R> /*l*/, integral_constant<Lhs, L> /*r*/)
28 -> integral_constant<decltype(L + R), L + R>
29{
30 return {};
31}
32
33template <typename Rhs, Rhs R, typename Lhs, Lhs L>
34[[nodiscard]] constexpr auto operator==(integral_constant<Rhs, R> /*l*/, integral_constant<Lhs, L> /*r*/)
35 -> integral_constant<bool, L == R>
36{
37 return {};
38}
39
40template <typename Rhs, Rhs R, typename Lhs, Lhs L>
41[[nodiscard]] constexpr auto operator!=(integral_constant<Rhs, R> /*l*/, integral_constant<Lhs, L> /*r*/)
42 -> integral_constant<bool, L != R>
43{
44 return {};
45}
46
47} // namespace etl
48
49#endif // TETL_TYPE_TRAITS_INTEGRAL_CONSTANT_HPP
Definition adjacent_find.hpp:9
constexpr auto operator==(integral_constant< Rhs, R >, integral_constant< Lhs, L >) -> integral_constant< bool, L==R >
Definition integral_constant.hpp:34
constexpr auto operator!=(integral_constant< Rhs, R >, integral_constant< Lhs, L >) -> integral_constant< bool, L !=R >
Definition integral_constant.hpp:41
constexpr auto operator+(integral_constant< Rhs, R >, integral_constant< Lhs, L >) -> integral_constant< decltype(L+R), L+R >
Definition integral_constant.hpp:27
Definition integral_constant.hpp:10
constexpr operator value_type() const noexcept
Definition integral_constant.hpp:15
constexpr auto operator()() const noexcept -> value_type
Definition integral_constant.hpp:20
static constexpr Type value
Definition integral_constant.hpp:11