libsemigroups  v3.1.2
C++ library for semigroups and monoids
Loading...
Searching...
No Matches
types.hpp
1//
2// libsemigroups - C++ library for semigroups and monoids
3// Copyright (C) 2019-2025 James D. Mitchell
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <http://www.gnu.org/licenses/>.
17//
18
19#ifndef LIBSEMIGROUPS_TYPES_HPP_
20#define LIBSEMIGROUPS_TYPES_HPP_
21
22#include <cstddef> // for size_t
23#include <cstdint> // for uint8_t, uint16_t, uint32_t, uint64_t
24#include <string_view> // for string_view
25#include <type_traits> // for conditional
26#include <utility> // for pair
27#include <vector> // for vector
28
29#include "detail/fmt.hpp"
30#include <magic_enum/magic_enum.hpp>
31
32namespace libsemigroups {
41
47 template <typename Given, typename Expected>
49 = std::enable_if_t<std::is_same_v<Given, Expected>, Expected>;
50
54 //! or not currently knowable.
55 enum class tril {
57 FALSE = 0,
59 TRUE = 1,
61 unknown = 2
62 };
63
67 //! be 2-sided, left, or right.
68 enum class congruence_kind {
70 onesided = 1,
72 twosided = 2
73 };
74
84 template <size_t N>
85 struct SmallestInteger {
88 using type = std::conditional_t<
89 N >= 0x100000000,
90 uint64_t,
91 std::conditional_t<N >= 0x10000,
92 uint32_t,
93 std::conditional_t<N >= 0x100, uint16_t, uint8_t>>>;
94 };
95
97 using letter_type = size_t;
98
101
104
106 // There is undefined behaviour associated with std::char_traits and
107 // std::basic_string<uint8_t>. This only seems to present an issue in Cygwin,
108 // and in the conda feedstock tests. This alias was only used in v3.1.0 and
109 // is deprecated already in v3.1.1.
110 using u8string [[deprecated]] = std::basic_string<uint8_t>;
112} // namespace libsemigroups
113
114#endif // LIBSEMIGROUPS_TYPES_HPP_
std::enable_if_t< std::is_same_v< Given, Expected >, Expected > enable_if_is_same
Alias equal to the second template parameter if both template parameters are equal.
Definition types.hpp:48
std::vector< letter_type > word_type
Type for a word over the generators of a semigroup.
Definition types.hpp:99
size_t letter_type
Type for the index of a generator of a semigroup.
Definition types.hpp:96
std::pair< word_type, word_type > relation_type
Type for a pair of word_type (a relation) of a semigroup.
Definition types.hpp:102
tril
Enum to indicate true, false or not currently knowable.
Definition types.hpp:54
congruence_kind
Enum to indicate the sided-ness of a congruence.
Definition types.hpp:67
@ FALSE
Value representing false.
Definition types.hpp:56
@ unknown
Value representing unknown (either true or false).
Definition types.hpp:60
@ TRUE
Value representing true.
Definition types.hpp:58
@ twosided
Value representing a two-sided congruence.
Definition types.hpp:71
@ onesided
Value representing a one-sided congruence.
Definition types.hpp:69
Namespace for everything in the libsemigroups library.
Definition action.hpp:44
Type giving the smallest unsigned integer type that can represent a template.
Definition types.hpp:84
std::conditional_t< N >=0x100000000, uint64_t, std::conditional_t< N >=0x10000, uint32_t, std::conditional_t< N >=0x100, uint16_t, uint8_t > > > type
Definition types.hpp:87