Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Stroika::Foundation::Common::DefaultNames< ENUM_TYPE > Struct Template Reference

#include <Enumeration.h>

Inheritance diagram for Stroika::Foundation::Common::DefaultNames< ENUM_TYPE >:

Detailed Description

template<typename ENUM_TYPE>
struct Stroika::Foundation::Common::DefaultNames< ENUM_TYPE >

Use DefaultNames<> to register the EnumNames<> mapping in a common place that can be used by other templates to automatically lookup enum names.

Example Usage
enum class Priority {
a, b, c
};
// this template specialization must be located in the Stroika::Common namespace
template<>
constexpr EnumNames<Priority> DefaultNames<Priority>::k{{{
{Priority::a, L"Debug"},
{Priority::b, L"Info"},
{Priority::eNotice, L"Notice"},
}}};
}
// Then use
const wchar_t* aStr = DefaultNames<Priority>{}.PeekName (Priority::a);
Priority p = DefaultNames<Priority>{}.GetValue (L"invalid", Execution::Exception<> (L"OutOfRange")); // this will throw - out of range
#define Stroika_Define_Enum_Bounds(FIRST_ITEM, LAST_ITEM)

Definition at line 288 of file Enumeration.h.


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