tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
is_bitmask_type.hpp
Go to the documentation of this file.
1
2
3// SPDX-License-Identifier: BSL-1.0
4
5#ifndef TETL_BIT_IS_BITMASK_TYPE_HPP
6#define TETL_BIT_IS_BITMASK_TYPE_HPP
7
10
11namespace etl {
12template <typename T>
14
15template <typename T>
17
18template <typename T>
20
21template <bitmask_type T>
22[[nodiscard]] constexpr auto operator&(T x, T y) -> T
23{
24 using type = underlying_type_t<T>;
25 return T{static_cast<type>(static_cast<type>(x) & static_cast<type>(y))};
26}
27
28template <bitmask_type T>
29[[nodiscard]] constexpr auto operator|(T x, T y) -> T
30{
31 using type = underlying_type_t<T>;
32 return T{static_cast<type>(static_cast<type>(x) | static_cast<type>(y))};
33}
34
35template <bitmask_type T>
36[[nodiscard]] constexpr auto operator^(T x, T y) -> T
37{
38 using type = underlying_type_t<T>;
39 return T{static_cast<type>(static_cast<type>(x) ^ static_cast<type>(y))};
40}
41
42template <bitmask_type T>
43[[nodiscard]] constexpr auto operator~(T x) -> T
44{
45 using type = underlying_type_t<T>;
46 return T{static_cast<type>(~static_cast<type>(x))};
47}
48
49template <bitmask_type T>
50constexpr auto operator|=(T& x, T y) noexcept -> T const&
51{
52 return x = x | y;
53}
54
55template <bitmask_type T>
56constexpr auto operator&=(T& x, T y) noexcept -> T const&
57{
58 return x = x & y;
59}
60
61template <bitmask_type T>
62constexpr auto operator^=(T& x, T y) noexcept -> T const&
63{
64 return x = x ^ y;
65}
66
67} // namespace etl
68#endif // TETL_BIT_IS_BITMASK_TYPE_HPP
Definition is_bitmask_type.hpp:19
typename underlying_type< T >::type underlying_type_t
Definition underlying_type.hpp:31
Definition adjacent_find.hpp:8
constexpr auto operator&=(T &x, T y) noexcept -> T const &
Definition is_bitmask_type.hpp:56
constexpr auto operator~(T x) -> T
Definition is_bitmask_type.hpp:43
constexpr auto operator|(T x, T y) -> T
Definition is_bitmask_type.hpp:29
constexpr auto operator^(T x, T y) -> T
Definition is_bitmask_type.hpp:36
constexpr auto operator&(T x, T y) -> T
Definition is_bitmask_type.hpp:22
constexpr auto operator^=(T &x, T y) noexcept -> T const &
Definition is_bitmask_type.hpp:62
bool_constant< false > false_type
Definition bool_constant.hpp:14
constexpr auto is_bitmask_type_v
Definition is_bitmask_type.hpp:16
constexpr auto operator|=(T &x, T y) noexcept -> T const &
Definition is_bitmask_type.hpp:50
static constexpr bool value
Definition integral_constant.hpp:10
Definition is_bitmask_type.hpp:13