25 #ifndef GZ_COMMON_FLAGSET_HH
26 #define GZ_COMMON_FLAGSET_HH
58 template<
typename T, T LastElement = T::_,
bool ExcludeLast = true>
72 flags.
set(
static_cast<UnderlyingType
>(_val));
79 for (
const auto& val : _list)
81 flags.
set(
static_cast<UnderlyingType
>(val));
93 bool tmp = flags.
test(
static_cast<UnderlyingType
>(_val));
95 flags.
set(
static_cast<UnderlyingType
>(_val), tmp);
113 flags.
set(
static_cast<UnderlyingType
>(_val));
136 assert(ret.flags.
count() <= 1);
146 ret.flags &= _val.flags;
160 assert(ret.flags.
count() >= 1);
170 ret.flags |= _val.flags;
187 public:
explicit operator bool()
const
199 return flags == _o.flags;
207 return !(*
this == _o);
224 return flags.
count();
257 flags.
set(
static_cast<UnderlyingType
>(_val), _value);
266 flags.
reset(
static_cast<UnderlyingType
>(_val));
275 flags.
flip(
static_cast<UnderlyingType
>(_val));
318 return flags[
static_cast<size_t>(
static_cast<UnderlyingType
>(_val))];
335 return _stream << _self.flags;
342 return std::hash<decltype(this->flags)>{}(this->flags);
346 private:
using UnderlyingType = std::underlying_type_t<T>;
349 public:
static constexpr
size_t numElements =
static_cast<size_t>(
350 static_cast<UnderlyingType
>(LastElement) +
351 static_cast<UnderlyingType
>(1 - ExcludeLast));
357 template<
typename T,
typename =
void>
388 template<
typename T, T LastElement,
bool ExcludeLast>
389 struct hash<
gz::common::FlagSet<T, LastElement, ExcludeLast>>