xtd 0.2.0
xtd::enum_set_attribute< enum_t > Struct Template Reference

#include <enum_set_attribute.h>

Definition

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

Provides the set attribute struct for enumerations.

template<typename enum_t>
struct 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::ustring::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;}
};

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