diff --git a/CMakeLists.txt b/CMakeLists.txt index dda94e1..d350fa4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.23) project(YYCC - VERSION 1.2.0 + VERSION 1.3.0 LANGUAGES CXX ) diff --git a/src/YYCC/EnumHelper.hpp b/src/YYCC/EnumHelper.hpp index 440dddc..043b13a 100644 --- a/src/YYCC/EnumHelper.hpp +++ b/src/YYCC/EnumHelper.hpp @@ -88,8 +88,13 @@ namespace YYCC::EnumHelper { /** * @brief Merge given enum flags like performing e1 | e2 | ... | en * @tparam TEnum Enum type for processing. - * @param[in] il The list of enum flags to be merged. + * @param[in] val The first enum flag to be merged. + * @param[in] val_left Left enum flags to be merged. * @return The merged enum flag. + * @remarks + * This function use recursive expansion to get final merge result. + * So there is no difference of each arguments. + * We independ first argument just served for expansion. */ template, int> = 0> constexpr TEnum Merge(TEnum val, Ts... val_left) { @@ -114,7 +119,7 @@ namespace YYCC::EnumHelper { } /** - * @brief Use specified enum flags to mask given enum flags like performing e1 &= e2 + * @brief Use specified enum flag to mask given enum flag like performing e1 &= e2 * @tparam TEnum Enum type for processing. * @param[in,out] e1 The enum flags to be masked. * @param[in] e2 The mask enum flag. @@ -126,10 +131,10 @@ namespace YYCC::EnumHelper { } /** - * @brief Add specified enum flags to given enum flags like performing e1 = e1 | e2 | ... | en + * @brief Add multiple enum flags to given enum flag like performing e1 |= (e2 | e3 | ... | en) * @tparam TEnum Enum type for processing. - * @param[in,out] e1 The enum flags to be processed. - * @param[in] e2 The enum flag to be added. + * @param[in,out] e1 The enum flag which flags add on. + * @param[in] vals The enum flag to be added. */ template, int> = 0> constexpr void Add(TEnum& e1, Ts... vals) { @@ -138,10 +143,10 @@ namespace YYCC::EnumHelper { } /** - * @brief Remove specified enum flags from given enum flags like performing e1 &= ~(e2 | e3 | ... | en) + * @brief Remove multiple enum flags from given enum flag like performing e1 &= ~(e2 | e3 | ... | en) * @tparam TEnum Enum type for processing. - * @param[in,out] e1 The enum flags to be processed. - * @param[in] e2 The enum flag to be removed. + * @param[in,out] e1 The enum flag which flags removed from. + * @param[in] vals The enum flag to be removed. */ template, int> = 0> constexpr void Remove(TEnum& e1, Ts... vals) { @@ -150,23 +155,23 @@ namespace YYCC::EnumHelper { } /** - * @brief Check whether given enum flags has specified enum flag like performing bool(e & probe) + * @brief Check whether given enum flag has any of specified multiple enum flags (OR) like performing bool(e1 & (e2 | e3 | ... | en)) * @tparam TEnum Enum type for processing. - * @param[in] e1 The enum flags to be checked. - * @param[in] e2 The enum flag for checking. - * @return True if it has, otherwise false. + * @param[in] e1 The enum flag where we check. + * @param[in] vals The enum flags for checking. + * @return True if it has any of given flags (OR), otherwise false. */ - template, int> = 0> - constexpr bool Has(TEnum e1, TEnum e2) { + template, int> = 0> + constexpr bool Has(TEnum e1, Ts... vals) { using ut = std::underlying_type_t; - return static_cast(static_cast(e1) & static_cast(e2)); + return static_cast(static_cast(e1) & static_cast(Merge(vals...))); } /** * @brief Cast given enum flags to its equvalent boolean value like performing bool(e) * @tparam TEnum Enum type for processing. * @param e The enum flags to be cast. - * @return The cast enum flag. + * @return The equvalent bool value of given enum flag. */ template, int> = 0> constexpr bool Bool(TEnum e) {