libsemigroups
v3.6.3
C++ library for semigroups and monoids
Toggle main menu visibility
Loading...
Searching...
No Matches
value-guard.hpp
1
//
2
// libsemigroups - C++ library for semigroups and monoids
3
// Copyright (C) 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_DETAIL_VALUE_GUARD_HPP_
20
#define LIBSEMIGROUPS_DETAIL_VALUE_GUARD_HPP_
21
22
#include <atomic>
// for std::atomic
23
24
#include "libsemigroups/is_specialization_of.hpp"
// for is_specialization_of
25
26
namespace
libsemigroups::detail {
27
// A simple class for ensuring that a value is set back to its value at the
28
// time of the creation of the ValueGuard. Probably should only be used with
29
// POD types for Thing.
30
template
<
typename
Thing>
31
class
ValueGuard {
32
Thing _value_old;
33
Thing& _value_ref;
34
35
public
:
36
ValueGuard() =
delete
;
37
ValueGuard(ValueGuard
const
&) =
delete
;
38
ValueGuard(ValueGuard&&) =
delete
;
39
ValueGuard& operator=(ValueGuard
const
&) =
delete
;
40
ValueGuard& operator=(ValueGuard&&) =
delete
;
41
42
explicit
ValueGuard(Thing& value);
43
~ValueGuard();
44
};
45
}
// namespace libsemigroups::detail
46
47
#include "value-guard.tpp"
48
#endif
// LIBSEMIGROUPS_DETAIL_VALUE_GUARD_HPP_
include
libsemigroups
detail
value-guard.hpp
Generated by
1.18.0