Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
TSet.h
Go to the documentation of this file.
1#pragma once
2#include <type_traits>
3
4namespace sf
5{
6
12template<typename T = int, typename S = int>
13class TSet
14{
15 public:
16 static_assert(std::is_integral_v<T> || std::is_enum_v<T> || std::is_integral_v<S> || std::is_enum_v<S>, "Type S and T must be an integral or enum type.");
21
25 TSet(const TSet& set)
26 : _bits(set._bits)
27 {}
28
32 explicit TSet(S bits);
33
37 S& getBits();
38
42 S getBits() const;
43
48
52 bool has(T bit) const;
53
57 TSet& set(T bit);
58
63
67 TSet& unset(T bit);
68
72 TSet& toggle(T bit);
73
77 bool operator==(const TSet& set) const;
78
82 bool operator!=(const TSet& set) const;
83
88 bool contains(T bit) const;
89
94
99
100 private:
104 S _bits;
105};
106
107}// namespace sf
108
109// Include all inlined functions and template implementations.
110#include <misc/gen/TSet.hpp>
Template class for managing bit maks preferably when bits are defined as enumerate values.
Definition TSet.h:14
bool contains(T bit) const
Operators and functions that are also available in the VCL 'Set' template.
bool operator!=(const TSet &set) const
Compare unequal operator.
TSet(const TSet &set)
Copy constructor.
Definition TSet.h:25
TSet & operator<<(T bit)
Operator for adding bits to the mask.
TSet & operator=(const TSet &set)
assign operator.
TSet & reset()
Resets all bits in the mask.
TSet & unset(T bit)
Unsets bits in the mask.
TSet & toggle(T bit)
Toggles a bit in the mask.
TSet & operator>>(T bit)
Operator for removing bits from the mask.
S & getBits()
Gets a reference to the storage integral typed value.
bool operator==(const TSet &set) const
Compare equal operator.
TSet(S bits)
Initializing constructor.
TSet & set(T bit)
Sets bits in the mask.
bool has(T bit) const
Returns true when the bit was Set.
S getBits() const
Gets a copy of the storage integral typed value.
Definition Application.h:10