Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
FinalStateLabel.h
Go to the documentation of this file.
1
6/*
7 * This file is part of Algorithms library toolkit.
8 * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
9
10 * Algorithms library toolkit is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14
15 * Algorithms library toolkit is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19
20 * You should have received a copy of the GNU General Public License
21 * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#pragma once
25
26#include <compare>
27#include <limits>
28
29#include <object/Object.h>
30
31namespace label {
32
38public:
43 explicit FinalStateLabel ( );
44
52 std::strong_ordering operator <=> ( const FinalStateLabel & ) const {
53 return std::strong_ordering::equal;
54 }
55
63 bool operator == ( const FinalStateLabel & ) const {
64 return true;
65 }
66
76
80 template < typename Base >
81 static inline Base instance ( );
82};
83
84template < typename Base >
86 if constexpr ( std::is_integral_v < Base > ) {
88 } else if constexpr ( std::is_same_v < Base, std::string > ) {
89 return std::string ( "final" );
90 } else if constexpr ( std::is_same_v < Base, FinalStateLabel > ) {
91 return FinalStateLabel ( );
92 } else if constexpr ( std::is_same_v < Base, object::Object > ) {
93 return object::Object ( FinalStateLabel ( ) );
94 } else {
95 static_assert ( std::is_same_v < Base, Base >, "Unsupported type of instance" );
96 }
97}
98
99} /* namespace label */
100
Definition: ostream.h:14
Represents label of the final state of an automaton.
Definition: FinalStateLabel.h:37
std::strong_ordering operator<=>(const FinalStateLabel &) const
Definition: FinalStateLabel.h:52
FinalStateLabel()
Creates a new instance of the label.
bool operator==(const FinalStateLabel &) const
Definition: FinalStateLabel.h:63
friend ext::ostream & operator<<(ext::ostream &out, const FinalStateLabel &instance)
Definition: FinalStateLabel.cpp:16
static Base instance()
Factory for the label construction of the label based on given type.
Definition: FinalStateLabel.h:85
Definition: Object.h:16
constexpr const T & max(const T &a)
Root case of maximum computation. The maximum from one value is the value itself.
Definition: algorithm.hpp:278
Definition: FailStateLabel.cpp:12