API Reference


Disclaimer: docs are currently quite out of sync!

Header <flags/flagsfwd.hpp>

namespace flags {

template <class E> class flags;

} // namespace flags

Forward declaration of flags template.

Header <flags/allow_flags.hpp>

Work in progress…

Header <flags/flags.hpp>

Synopsis

namespace flags {

template <class E> class flags {
/* ... */
};

} // namespace flags

where E is an enum.

Member types

Member type Definition Notes
enum_type The template parameter (E)  
underlying_type The integer type that is used as representation of flags Equivalent of std::underlying_type<E>::type

Member functions

Constructors and assignment operators
Name Description
flags() Default contructor, keeps object uninitialized (note: object may contain garbage)
flags(empty_t) Unsets all flags
flags(flags::enum_type) Sets flag denoted by the parameter
flags(const flags&) Copy constructor
flags(flags&&) Move constructor
operator=(flags::enum_type) Unsets all flags, then sets flag denoted by the parameter
operator=(const flags&) Copy assignment
operator=(flags&&) Move assignment
Bitwise operators

All functions in this group return reference to flags, except for operator~ which returns a new flags value.

Name Description
operator|=(flags::enum_type) Bitwise OR with flag denoted by the parameter
operator|=(const flags&) Bitwise OR with flags in the parameter
operator&=(flags::enum_type) Bitwise AND with flag denoted by the parameter`
operator&=(const flags&) Bitwise AND with flags in the parameter
operator^=(flags::enum_type) Bitwise XOR with flag denoted by the parameter
operator^=(const flags&) Bitwise XOR with flags in the parameter
operator~() Bitwise negation
Boolean conversions
Name Description
operator bool() Returns true if any of the flags is set
operator!() Returns true if none of the flags is set
Raw access to integer representation
Name Description
underlying_value() Returns integer representation
set_underlying_value(flags::underlying_type) Sets integer representation to new value
Various functions
Name Description
swap(flags) Swaps two flags values

Nonmember functions

Bitwise operators

All functions in this group return new flags value.

Name Description
operator|(flags, flags) Bitwise OR of two flags values
operator|(flags, flags::enum_type) Bitwise OR of a flags value and a flag denoted by an enum value
operator|(flags::enum_type, flags) Bitwise OR of a flags value and a flag denoted by an enum value
operator|(flags::enum_type, flags::enum_type) Bitwise OR of two flags denoted by enum values
operator&(flags, flags) Bitwise AND of two flags values
operator&(flags, flags::enum_type) Bitwise AND of a flags value and a flag denoted by an enum value
operator&(flags::enum_type, flags) Bitwise AND of a flags value and a flag denoted by an enum value
operator&(flags::enum_type, flags::enum_type) Bitwise AND of two flags denoted by enum values
operator^(flags, flags) Bitwise XOR of two flags values
operator^(flags, flags::enum_type) Bitwise XOR of a flags value and a flag denoted by an enum value
operator^(flags::enum_type, flags) Bitwise XOR of a flags value and a flag denoted by an enum value
operator^(flags::enum_type, flags::enum_type) Bitwise XOR of two flags denoted by enum values
Comparison operators

All functions in this group return bool.

Name Description
operator==(flags, flags) Compares if two flags values are equal
operator!=(flags, flags) Compares if two flags values are not equal

Header <flags/iterator.hpp>

Work in progress…