xtd 0.2.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.h:31
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.

Public Member Functions

 operator auto () const noexcept
 

Member Function Documentation

◆ operator auto()

template<typename enum_t >
xtd::enum_set_attribute< enum_t >::operator auto ( ) const
inlineexplicitnoexcept

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<>
explicit operator auto() const noexcept {return xtd::enum_attribute::flags;}
};
@ flags
Enum flags attribute.

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