diff --git a/include/ircd/util.h b/include/ircd/util.h index 738082690..f938ce416 100644 --- a/include/ircd/util.h +++ b/include/ircd/util.h @@ -557,6 +557,28 @@ operator^=(Enum &a, const Enum &b) return (a = (a ^ b)); } +template +typename std::enable_if::value, typename std::underlying_type::type>::type +combine_flags(const it &begin, + const it &end) +{ + using type = typename std::underlying_type::type; + + return std::accumulate(begin, end, type(0), [] + (auto ret, const auto &val) + { + return ret |= type(val); + }); +} + +template +typename std::enable_if::value, typename std::underlying_type::type>::type +combine_flags(const std::initializer_list &list) +{ + return combine_flags(begin(list), end(list)); +} + inline size_t size(std::ostream &s)