#include <enum_register.h>
template<typename enum_t>
struct xtd::enum_register< enum_t >
Provides the registration struct for enumerations.
template<typename enum_t>
struct enum_register
- Namespace
- xtd
- Library
- xtd.core
- Examples
- The following code show how to use xtd::enum_register operator for an enum.
#include <xtd/xtd>
enum class enum_test {
value_one,
value_two,
value_three,
value_four
};
explicit operator auto()
const noexcept {
return xtd::enum_collection<enum_test> {{enum_test::value_one,
"value_one"}, {enum_test::value_two,
"value_two"}, {enum_test::value_three,
"value_three"}, {enum_test::value_four,
"value_four"}};}
};
auto main()->int {
}
The following code show how to use xtd::enum_register operator for an enum flags. #include <xtd/xtd>
enum class text_attribute {
};
};
explicit operator auto()
const noexcept {
return xtd::enum_collection<text_attribute> {{text_attribute::normal,
"normal"}, {text_attribute::bold,
"bold"}, {text_attribute::italic,
"italic"}, {text_attribute::underline,
"underline"}, {text_attribute::strikeout,
"strikeout"}};}
};
auto main()->int {
}
- Examples:
- enum_class_flags_without_helpers.cpp, enum_class_without_helper.cpp, format_enum.cpp, format_enum_class.cpp, format_enum_class_flags.cpp, and format_enum_class_flags_without_helper.cpp.
◆ operator auto()
template<typename enum_t >
Allows to register an enumeration that can be used by xtd::enum_object.
- Returns
- An xtd::enum_collection collection that represent enumeration.
- Examples
- The following code show how to register the values enum class.
enum class values {
value_one,
value_two
};
template<>
explicit operator auto()
const noexcept {
return xtd::enum_collection<values> {{values::value_one,
"value_one"}, {values::value_two,
"value_two"}};}
};
The documentation for this struct was generated from the following file: