Browse Source

Add helper to modify a flag enum

charconv
Martchus 12 months ago
parent
commit
9e940a7858
  1. 2
      CMakeLists.txt
  2. 9
      misc/flagenumclass.h

2
CMakeLists.txt

@ -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

9
misc/flagenumclass.h

@ -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

Loading…
Cancel
Save