Add helper to modify a flag enum

This commit is contained in:
Martchus 2020-12-14 20:56:37 +01:00
parent 6905b1a216
commit 9e940a7858
2 changed files with 10 additions and 1 deletions

View File

@ -113,7 +113,7 @@ set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
set(META_APP_DESCRIPTION "Useful C++ classes and routines such as argument parser, IO and conversion utilities")
set(META_FEATURES_FOR_COMPILER_DETECTION_HEADER cxx_thread_local)
set(META_VERSION_MAJOR 5)
set(META_VERSION_MINOR 9)
set(META_VERSION_MINOR 10)
set(META_VERSION_PATCH 0)
# find required 3rd party libraries

View File

@ -76,6 +76,15 @@ constexpr FlagEnumClass &operator-=(FlagEnumClass &lhs, FlagEnumClass rhs)
} // namespace FlagEnumClassOperations
/*!
* \brief Sets the specified \a relevantFlags in the specified \a flagVariable to the specified \a value.
*/
template <typename FlagEnumClass, Traits::EnableIf<IsFlagEnumClass<FlagEnumClass>> * = nullptr>
constexpr FlagEnumClass &modFlagEnum(FlagEnumClass &flagVariable, FlagEnumClass relevantFlags, bool value)
{
return value ? (flagVariable += relevantFlags) : (flagVariable -= relevantFlags);
}
} // namespace CppUtilities
#endif // CPP_UTILITIES_FLAG_ENUM_CLASS_H