commons 0.1.5
Header-only C++23 library of common/shared types for the C++ libraries
Loading...
Searching...
No Matches
comms::FlagBuilderMixin< Derived, Categories > Class Template Reference

CRTP helper for builders. More...

#include <flag.hpp>

Collaboration diagram for comms::FlagBuilderMixin< Derived, Categories >:

Public Member Functions

template<AnyFlag F>
requires AllowedFlag<F, Categories...>
Derived & insert_flag ()
 Insert flag F (no-op if already present).
 
template<AnyFlag F>
requires AllowedFlag<F, Categories...>
Derived & flag ()
 Alias for insert_flag that reads naturally in a fluent chain (builder.flag<F>()).
 
template<AnyFlag F>
requires AllowedFlag<F, Categories...>
Derived & set_flag (const bool on)
 Set flag F's presence: insert when on, erase otherwise.
 
Derived & set_flags (FlagSet flags)
 Replace the whole set.
 

Static Public Attributes

template<AnyFlag F>
static constexpr bool flag_allowed = AllowedFlag<F, Categories...>
 True when a flag in F's category is permitted by this builder's constraint.
 

Protected Member Functions

const FlagSetflags () const noexcept
 Read access kept protected and used internally; FlagBuilderGetters publishes it through IHasFlags.
 

Detailed Description

template<typename Derived, typename... Categories>
class comms::FlagBuilderMixin< Derived, Categories >

CRTP helper for builders.

Owns its own FlagSet and adds fluent mutators that return Derived& for chaining.

It does not expose the set publicly or implement IHasFlags: flags() is protected, used internally. A builder that should keep its flags to itself inherits this directly; one that should be observable inherits FlagBuilderGetters instead.

The typed overloads are constrained to allowed categories; the runtime FlagRef/name overloads are unconstrained (the category is only known at compile time), so prefer the typed ones to keep the constraint.

Member Function Documentation

◆ insert_flag()

template<typename Derived , typename... Categories>
template<AnyFlag F>
requires AllowedFlag<F, Categories...>
Derived & comms::FlagBuilderMixin< Derived, Categories >::insert_flag ( )
inline

Insert flag F (no-op if already present).

Constrained to allowed categories.


The documentation for this class was generated from the following file: