xtd 1.0.0
Loading...
Searching...
No Matches
xtd::enum_set_attribute< enum_t > Struct Template Reference

Definition

template<typename enum_t>
struct xtd::enum_set_attribute< enum_t >

Provides the set attribute struct for enumerations.

template<typename enum_t>
Provides the set attribute struct for enumerations.
Definition enum_set_attribute.hpp:36
Header
#include <xtd/enum_set_attribute>
Namespace
xtd
Library
xtd.core
Remarks
The overloading of this operator is necessary for enum classes to be recognized as having a flags attribute to be properly handled by xtd::string::format().
For more information about enumeration, see enum class guide.
When an enumeration is registered, we can display its name instead of its value, we can format it and parse it.
See Enumeration Format Strings. For more information about formatting in general, see Formatting Types.
Examples
The following code show how to use xtd::enum_set_attribute operator.
Examples
enum_class_flags_without_helpers.cpp, and format_enum_class_flags_without_helper.cpp.

Static Public Member Functions

static auto attribute () noexcept

Member Function Documentation

◆ attribute()

template<typename enum_t>
auto xtd::enum_set_attribute< enum_t >::attribute ( )
inlinestaticnoexcept

Allows to set attribute to an enumeration that can be used by xtd::enum_object.

Returns
One of xtd::enum_attribute values.
Remarks
To set attribute to an enumeration just override xtd::enum_set_attribute.
Examples
The following code show how to set attribute to the value_flags enum class.
enum class value_flags {
value_none = 0,
value_one = 0b1,
value_two = 0b10,
value_three = 0b100,
};
template<>
static auto values() noexcept {return xtd::enum_attribute::flags;}
};
@ flags
Enum flags attribute.
Definition enum_attribute.hpp:26
Examples
enum_class_flags_without_helpers.cpp, and format_enum_class_flags_without_helper.cpp.

The documentation for this struct was generated from the following file: