/// Bi-directional iterator for flag set. Iterates over flags that are set in this field.
class iterator
: public std::iterator<std::bidirectional_iterator_tag, Flag>
/// Bi-directional iterator for flag set. Iterates over flags that are set in this field.
class iterator
: public std::iterator<std::bidirectional_iterator_tag, Flag>
public:
iterator (FlagField const & parent, Flag position) : parent (parent), position (position) {}
iterator (iterator const & other) : parent (other.parent), position (other.position) {}
public:
iterator (FlagField const & parent, Flag position) : parent (parent), position (position) {}
iterator (iterator const & other) : parent (other.parent), position (other.position) {}
value_type operator*() const { return position; }
value_type const * operator->() const { return &position; }
value_type operator*() const { return position; }
value_type const * operator->() const { return &position; }
inline bool has (Flag flag) const { return _flags & (1 << flag); }
inline storage_type flags () const { return _flags; }
inline operator bool() const { return _flags; }
inline bool has (Flag flag) const { return _flags & (1 << flag); }
inline storage_type flags () const { return _flags; }
inline operator bool() const { return _flags; }
/// Returns the flags in \a other that are not set in this field
inline FlagField unsupported_flags_of (FlagField const & other) const { return ~(_flags | ~other._flags); }
/// Returns the flags in \a other that are not set in this field
inline FlagField unsupported_flags_of (FlagField const & other) const { return ~(_flags | ~other._flags); }
/// Set all flags that are set in \a other
inline FlagField & operator+= (FlagField const & other) { _flags |= other._flags; return *this; }
/// Set all flags that are set in \a other
inline FlagField & operator+= (FlagField const & other) { _flags |= other._flags; return *this; }
/** Checks whether this field has all the flags set that are set in \a other
* NOTE: Can NOT be used for strict weak ordering!
* \return \a true if \a other has flags set that this field does not
/** Checks whether this field has all the flags set that are set in \a other
* NOTE: Can NOT be used for strict weak ordering!
* \return \a true if \a other has flags set that this field does not
private:
FlagField(storage_type flags) : _flags (flags) {}
static Flag max() { return CHAR_BIT * sizeof (storage_type) + 1; }
private:
FlagField(storage_type flags) : _flags (flags) {}
static Flag max() { return CHAR_BIT * sizeof (storage_type) + 1; }