|
TuringSim
C++ framework to simulate abstract computing models
|
3 #include <state/statePattern.h>
21 static_assert(std::is_same_v<StateType, T>);
22 static_assert(std::is_same_v<MatcherType, std::monostate>);
29 acceptedState(acceptedState)
37 acceptedState(other.acceptedState)
45 acceptedState(std::move(other.acceptedState))
55 acceptedState = other.acceptedState;
67 acceptedState = std::move(other.acceptedState);
90 virtual std::optional<MatcherType>
match(
const T& state)
const noexcept
override {
91 if(acceptedState == state) {
92 return std::monostate();
102 return acceptedState < other.acceptedState;
constexpr SimpleStatePattern & operator=(const SimpleStatePattern &other)
Copy a state pattern.
A simple explicit state pattern.
virtual ~SimpleStatePattern() override=default
Destructor.
std::monostate MatcherType
The type returned when a state matches the pattern.
constexpr SimpleStatePattern(const SimpleStatePattern &other)
Copy a state pattern.
constexpr const T & getState() const
get the accepting state
bool operator<(const SimpleStatePattern< T > &other) const
Total ordering of SimpleStatePattern.
virtual std::optional< MatcherType > match(const T &state) const noexcept override
Test if a state matches.
constexpr SimpleStatePattern & operator=(SimpleStatePattern &&other)
Move a state pattern.
The base class of all state patterns.
constexpr SimpleStatePattern(SimpleStatePattern &&other)
Move a state pattern.
constexpr StatePattern & operator=(const StatePattern &other)=default
Copy a state pattern.
constexpr SimpleStatePattern(const T &acceptedState)
Construct a simple configuration from the letter in parameter.
T StateType
The type of states matched.
The namespace for states and state patterns.