|
commons 0.1.5
Header-only C++23 library of common/shared types for the C++ libraries
|
An insertion-ordered set of unique flags, deduplicated by name. More...
#include <flag.hpp>
Public Member Functions | |
| template<AnyFlag F> | |
| bool | insert () |
| Insert a flag by type. | |
| bool | insert (const FlagRef &f) |
Insert a FlagRef, deduplicating by name. Returns true if newly added. | |
| std::size_t | count (const std::string_view name) const |
0 or 1 — flags are unique by name, so this mirrors std::set::count. | |
| bool | erase (const std::string_view name) |
Erase the flag with the given name. Returns true if one was removed. | |
| std::map< std::string_view, std::vector< FlagRef > > | group_by_category () const |
| Flags grouped by category name. | |
Static Public Member Functions | |
| template<AnyFlag... Fs> | |
| static FlagSet | of () |
| Build a set from a flag type pack, inserting each in order. | |
An insertion-ordered set of unique flags, deduplicated by name.
Backed by a std::vector<FlagRef> so iteration preserves insertion order — hence it wraps a vector and exposes std::set-style names rather than deriving from std::set, which would sort.
|
inline |
Flags grouped by category name.
Within each group, insertion order is preserved; the outer map is ordered by category name (std::map).
|
inline |
Insert a flag by type.
Returns true if it was newly added, false if a flag with the same name was already present.
|
inlinestatic |
Build a set from a flag type pack, inserting each in order.
Lets call sites stay terse: FlagSet::of<Flag1, Flag2>().