27#ifndef LIBSEMIGROUPS_CONSTANTS_HPP_
28#define LIBSEMIGROUPS_CONSTANTS_HPP_
39 constexpr T operator()() const noexcept {
40 static_assert(std::is_integral_v<T>,
41 "can only call Min with an integral type");
48 constexpr T operator()() const noexcept {
49 static_assert(std::is_integral_v<T>,
50 "can only call Max with an integral type");
55 template <
int64_t TOffset,
typename TMaxOrMin>
57 static_assert(std::is_same_v<TMaxOrMin, Max>
58 || std::is_same_v<TMaxOrMin, Min>,
59 "template parameter TMaxOrMin must be Max or Min");
62 Constant(Constant
const&) =
default;
63 Constant(Constant&&) =
default;
64 Constant& operator=(Constant
const&) =
default;
65 Constant& operator=(Constant&&) =
default;
66 ~Constant() =
default;
68 template <
typename T,
typename = std::enable_if_t<!std::is_enum_v<T>, T>>
69 constexpr operator T() const noexcept {
72 && (std::is_signed_v<T> || std::is_same_v<TMaxOrMin, Max>),
73 "the template parameter T must be an integral type, and either "
74 "unsigned or the template parameter TMaxOrMin must be Max.");
75 return TMaxOrMin().template operator()<T>() + TOffset;
107 using LimitMax = detail::Constant<-2, detail::Max>;
161#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
166 template <
int64_t R,
typename S,
typename T>
167 constexpr bool operator==(Constant<R, S>
const& lhs,
168 T
const& rhs)
noexcept {
169 return lhs.operator T() == rhs;
172 template <
int64_t R,
typename S,
typename T>
174 Constant<R, S>
const& rhs)
noexcept {
175 return rhs.operator T() == lhs;
178 template <
int64_t R1,
typename S1,
int64_t R2,
typename S2>
179 constexpr bool operator==(Constant<R1, S1>
const&,
180 Constant<R2, S2>
const&)
noexcept {
181 return std::is_same_v<S1, S2> && R1 == R2;
186 template <
int64_t R,
typename S,
typename T>
187 constexpr bool operator!=(Constant<R, S>
const& lhs,
188 T
const& rhs)
noexcept {
189 return !(lhs == rhs);
192 template <
int64_t R,
typename S,
typename T>
194 Constant<R, S>
const& rhs)
noexcept {
195 return !(lhs == rhs);
198 template <
int64_t R1,
typename S1,
int64_t R2,
typename S2>
199 constexpr bool operator!=(Constant<R1, S1>
const& lhs,
200 Constant<R2, S2>
const& rhs)
noexcept {
201 return !(lhs == rhs);
206 template <
int64_t R,
typename S,
typename T>
207 constexpr bool operator>(Constant<R, S>
const& lhs, T
const& rhs)
noexcept {
211 template <
int64_t R,
typename S,
typename T>
212 constexpr bool operator>(T
const& lhs, Constant<R, S>
const& rhs)
noexcept {
216 template <
int64_t R,
typename S>
217 constexpr bool operator>(Constant<R, S>
const&,
218 Constant<R, S>
const&)
noexcept {
222 template <
int64_t R,
typename S>
223 constexpr bool operator<(Constant<R, S>
const&,
224 Constant<R, S>
const&)
noexcept {
236 template <
typename T,
typename SFINAE =
bool>
238 -> std::enable_if_t<std::is_integral_v<T>
239 || std::is_same_v<NegativeInfinity, T>,
246 template <
typename T,
typename SFINAE =
bool>
248 -> std::enable_if_t<std::is_integral_v<T>
249 || std::is_same_v<NegativeInfinity, T>,
255 template <
typename T,
typename SFINAE =
bool>
257 -> std::enable_if_t<std::is_integral_v<T>, SFINAE> {
262 template <
typename T,
typename SFINAE =
bool>
264 -> std::enable_if_t<std::is_integral_v<T>, SFINAE> {
269 template <
typename T,
typename SFINAE =
bool>
270 constexpr auto operator<(
LimitMax const& lhs, T
const& rhs)
noexcept
271 -> std::enable_if_t<std::is_integral_v<T>, SFINAE> {
272 return lhs.operator T() < rhs;
276 template <
typename T,
typename SFINAE =
bool>
277 constexpr auto operator<(T
const& lhs,
LimitMax const& rhs)
noexcept
278 -> std::enable_if_t<std::is_integral_v<T>, SFINAE> {
279 return lhs < rhs.operator T();
282 template <
typename T,
typename SFINAE = T>
283 constexpr auto operator-(
LimitMax const& lhs, T
const& rhs)
noexcept
284 -> std::enable_if_t<std::is_integral_v<T>, SFINAE> {
285 return lhs.operator T() - rhs;
288 template <
typename T,
typename SFINAE = T>
289 constexpr auto operator-(T
const& lhs,
LimitMax const& rhs)
noexcept
290 -> std::enable_if_t<std::is_integral_v<T>, SFINAE> {
291 return lhs - rhs.operator T();
bool operator>(Bipartition const &x, Bipartition const &y)
Compare bipartitions.
Definition bipart.hpp:1658
bool operator!=(Bipartition const &x, Bipartition const &y)
Check bipartitions for inequality.
Definition bipart.hpp:1637
detail::Constant< 0, detail::Max > Undefined
Type for undefined values.
Definition constants.hpp:95
NegativeInfinity const NEGATIVE_INFINITY
Value for negative infinity.
detail::Constant<-1, detail::Max > PositiveInfinity
Type for positive infinity.
Definition constants.hpp:101
Undefined const UNDEFINED
Value for something undefined.
detail::Constant< 0, detail::Min > NegativeInfinity
Type for negative infinity.
Definition constants.hpp:113
PositiveInfinity const POSITIVE_INFINITY
Value for positive infinity.
LimitMax const LIMIT_MAX
Value for the maximum of something.
detail::Constant<-2, detail::Max > LimitMax
Type for the maximum value of something.
Definition constants.hpp:107
bool operator==(Presentation< Word > const &lhop, Presentation< Word > const &rhop)
Compare for equality.
Definition presentation.hpp:2475
Namespace for everything in the libsemigroups library.
Definition action.hpp:44