xtd 0.2.0
Loading...
Searching...
No Matches

◆ enum_ut_

#define enum_ut_ (   namespace_name,
  enum_t,
  underlying_t,
  ... 
)

#include <xtd.core/include/xtd/enum.h>

Provides the registration struct for enum with specified underlying type.

Header
#include <xtd/enum>
Library
xtd.core
Parameters
namespace_nameThe name of the the namespace. Empty if no namespace.
enum_typeThe name of the enum.
underlying_typeThe underying type.
...The enumeration list.
Remarks
This helper is created to facilitate to set the xtd::enum_register with the enumeration identifiers.
Warning
The helper has one limitiation :
  • The enumeration's cannot be in a class or struct. The enum must be in the global namespace or in a namespace hierarchy. If the enumeration is in a class or struct, add operators manually and use xtd::enum_register to register the enumeration identifiers.
Examples
The following code show how to use enum_ut_ helper.
#include <xtd/as>
#include <xtd/console>
#include <xtd/enum>
using namespace xtd;
enum_ut_(, enum_test, byte,
value_one,
value_two,
value_three,
value_four
);
auto main() -> int {
console::write_line("name = {}", enum_test::value_four);
console::write_line("value = {}", enum_object(enum_test::value_four).to_byte());
console::write_line("as<byte> = {}", as<byte>(enum_test::value_four));
console::write_line("values = {}", enum_object<>::get_values_as_int32<enum_test>());
console::write_line("names = {}", enum_object<>::get_names<enum_test>());
console::write_line("entries = {}", enum_object<>::get_entries_as_int32<enum_test>());
}
// This code produces the following output :
//
// name = value_four
// value = 3
// as<byte> = 3
// values = [0, 1, 2, 3]
// names = [value_one, value_two, value_three, value_four]
// entries = [(0, value_one), (1, value_two), (2, value_three), (3, value_four)]
Provides the base class for enumerations.
Definition enum_object.h:41
#define enum_ut_(namespace_name, enum_t, underlying_t,...)
Provides the registration struct for enum with specified underlying type.
Definition enum.h:30
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Examples
enum_ut.cpp.