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;
109 using LimitMax = detail::Constant<-2, detail::Max>;
163#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
168 template <
int64_t R,
typename S,
typename T>
169 constexpr bool operator==(Constant<R, S>
const& lhs,
170 T
const& rhs)
noexcept {
171 return lhs.operator T() == rhs;
174 template <
int64_t R,
typename S,
typename T>
176 Constant<R, S>
const& rhs)
noexcept {
177 return rhs.operator T() == lhs;
180 template <
int64_t R1,
typename S1,
int64_t R2,
typename S2>
181 constexpr bool operator==(Constant<R1, S1>
const&,
182 Constant<R2, S2>
const&)
noexcept {
183 return std::is_same_v<S1, S2> && R1 == R2;
188 template <
int64_t R,
typename S,
typename T>
189 constexpr bool operator!=(Constant<R, S>
const& lhs,
190 T
const& rhs)
noexcept {
191 return !(lhs == rhs);
194 template <
int64_t R,
typename S,
typename T>
196 Constant<R, S>
const& rhs)
noexcept {
197 return !(lhs == rhs);
200 template <
int64_t R1,
typename S1,
int64_t R2,
typename S2>
201 constexpr bool operator!=(Constant<R1, S1>
const& lhs,
202 Constant<R2, S2>
const& rhs)
noexcept {
203 return !(lhs == rhs);
208 template <
int64_t R,
typename S,
typename T>
209 constexpr bool operator>(Constant<R, S>
const& lhs, T
const& rhs)
noexcept {
213 template <
int64_t R,
typename S,
typename T>
214 constexpr bool operator>(T
const& lhs, Constant<R, S>
const& rhs)
noexcept {
218 template <
int64_t R,
typename S>
219 constexpr bool operator>(Constant<R, S>
const&,
220 Constant<R, S>
const&)
noexcept {
224 template <
int64_t R,
typename S>
225 constexpr bool operator<(Constant<R, S>
const&,
226 Constant<R, S>
const&)
noexcept {
238 template <
typename T,
typename SFINAE =
bool>
240 -> std::enable_if_t<std::is_integral_v<T>
241 || std::is_same_v<NegativeInfinity, T>,
248 template <
typename T,
typename SFINAE =
bool>
250 -> std::enable_if_t<std::is_integral_v<T>
251 || std::is_same_v<NegativeInfinity, T>,
257 template <
typename T,
typename SFINAE =
bool>
259 -> std::enable_if_t<std::is_integral_v<T>, SFINAE> {
264 template <
typename T,
typename SFINAE =
bool>
266 -> std::enable_if_t<std::is_integral_v<T>, SFINAE> {
271 template <
typename T,
typename SFINAE =
bool>
272 constexpr auto operator<(
LimitMax const& lhs, T
const& rhs)
noexcept
273 -> std::enable_if_t<std::is_integral_v<T>, SFINAE> {
274 return lhs.operator T() < rhs;
278 template <
typename T,
typename SFINAE =
bool>
279 constexpr auto operator<(T
const& lhs,
LimitMax const& rhs)
noexcept
280 -> std::enable_if_t<std::is_integral_v<T>, SFINAE> {
281 return lhs < rhs.operator T();
284 template <
typename T,
typename SFINAE = T>
285 constexpr auto operator-(
LimitMax const& lhs, T
const& rhs)
noexcept
286 -> std::enable_if_t<std::is_integral_v<T>, SFINAE> {
287 return lhs.operator T() - rhs;
290 template <
typename T,
typename SFINAE = T>
291 constexpr auto operator-(T
const& lhs,
LimitMax const& rhs)
noexcept
292 -> std::enable_if_t<std::is_integral_v<T>, SFINAE> {
293 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:97
NegativeInfinity const NEGATIVE_INFINITY
Value for negative infinity.
detail::Constant<-1, detail::Max > PositiveInfinity
Type for positive infinity.
Definition constants.hpp:103
Undefined const UNDEFINED
Value for something undefined.
detail::Constant< 0, detail::Min > NegativeInfinity
Type for negative infinity.
Definition constants.hpp:115
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:109
bool operator==(Presentation< Word > const &lhop, Presentation< Word > const &rhop)
Compare for equality.
Definition presentation.hpp:2346
Namespace for everything in the libsemigroups library.
Definition action.hpp:44