Loading...
Searching...
No Matches
add_enum_bitwise_operators.hpp
Go to the documentation of this file.
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: BSD-3-Clause
#pragma once
#include <type_traits>
#include <seqan3/core/platform.hpp>
namespace seqan3
{
template <typename t>
inline constexpr bool add_enum_bitwise_operators = false;
template <typename t>
constexpr t operator&(t lhs, t rhs) noexcept
requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
{
return static_cast<t>(static_cast<std::underlying_type_t<t>>(lhs) & static_cast<std::underlying_type_t<t>>(rhs));
}
template <typename t>
constexpr t operator|(t lhs, t rhs) noexcept
requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
{
return static_cast<t>(static_cast<std::underlying_type_t<t>>(lhs) | static_cast<std::underlying_type_t<t>>(rhs));
}
template <typename t>
constexpr t operator^(t lhs, t rhs) noexcept
requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
{
return static_cast<t>(static_cast<std::underlying_type_t<t>>(lhs) ^ static_cast<std::underlying_type_t<t>>(rhs));
}
template <typename t>
constexpr t operator~(t lhs) noexcept
requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
{
return static_cast<t>(~static_cast<std::underlying_type_t<t>>(lhs));
}
template <typename t>
constexpr t & operator&=(t & lhs, t rhs) noexcept
requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
{
lhs = lhs & rhs;
return lhs;
}
template <typename t>
constexpr t & operator|=(t & lhs, t rhs) noexcept
requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
{
lhs = lhs | rhs;
return lhs;
}
template <typename t>
constexpr t & operator^=(t & lhs, t rhs) noexcept
requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
{
lhs = lhs ^ rhs;
return lhs;
}
} // namespace seqan3
seqan3::operator|
auto operator|(validator1_type &&vali1, validator2_type &&vali2)
Enables the chaining of validators.
Definition validators.hpp:1120
enum_bitwise_operators::operator&
operator&(t lhs, t rhs)
Returns the binary & operator of lhs and rhs.
std::is_enum_v
T is_enum_v
seqan3
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
platform.hpp
Provides platform and dependency checks.
type_traits
std::underlying_type_t
Hide me