rttr::enum_flags< Enum > Class Template Reference
The enum_flags class template is used to store OR-combinations of enum values in a type-safe way. More...
#include <enum_flags.h>
Detailed Description
template<typename Enum>
class rttr::enum_flags< Enum >
The enum_flags class template is used to store OR-combinations of enum values in a type-safe way.
The values are stored internally inside an integer (unsigned or signed, depending on the underlying type of the enum). Using values from other enums or raw integer (except 0) with this class will result in a compile time error.
In order to use this class with your own enum, use RTTR_DECLARE_FLAGS() and RTTR_DECLARE_ENUM_FLAGS_OPERATORS().
Typical Usage
enum class my_option
{
ALL_DISABLED = 0,
OPTION_1 = 1,
OPTION_2 = 2,
OPTION_3 = 4,
OPTION_4 = 8
};
RTTR_DECLARE_FLAGS(my_options, my_option)
RTTR_DECLARE_ENUM_FLAGS_OPERATORS(my_options)
void my_func(my_options flags)
{
if (flags.test_flag(my_option::OPTION_1)
{
// ...
}
if (flags.test_flag(my_option::OPTION_2)
{
// ...
}
}
The documentation for this class was generated from the following file:
Generated on Sun Jul 12 2020 20:42:14 for rttr - 0.9.6 by doxygen.