tagval 0.2.0
Modern C++23 header-only library of tagged values (open/closed enumerations with metadata)
Loading...
Searching...
No Matches
macros.hpp File Reference

TAGVAL_* macros for declaring entries. More...

+ Include dependency graph for macros.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TAGVAL_DETAIL_USED
 
#define TAGVAL_ENTRY(Owner, TypeName, FuncName, ...)
 
#define TAGVAL_ENTRY_AS(Owner, TypeName, FuncName, Code, ...)
 
#define TAGVAL_EXTERN_ENTRY(Owner, TypeName, FuncName, ...)
 
#define TAGVAL_EXTERN_ENTRY_AS(Owner, TypeName, FuncName, Code, ...)
 
#define TAGVAL_DETAIL_PASTE2(a, b)   a##b
 
#define TAGVAL_DETAIL_PASTE(a, b)   TAGVAL_DETAIL_PASTE2(a, b)
 
#define TAGVAL_REGISTER_KIND(KindType)
 

Detailed Description

TAGVAL_* macros for declaring entries.

In-class macros (TAGVAL_ENTRY, TAGVAL_ENTRY_AS) live inside the kind class body and declare a nested Entry type plus a static accessor. The kind must list these entries in values_t so they are visible to all_values() (ClosedEnded) or to the compile-time portion of an OpenEnded merge.

External macros (TAGVAL_EXTERN_ENTRY, TAGVAL_EXTERN_ENTRY_AS) live at namespace scope and always register into OpenEndedRegistry<Owner> — there is no other reason to declare an entry outside its class.

Macro Definition Documentation

◆ TAGVAL_DETAIL_USED

#define TAGVAL_DETAIL_USED

◆ TAGVAL_ENTRY

#define TAGVAL_ENTRY (   Owner,
  TypeName,
  FuncName,
  ... 
)
Value:
struct TypeName : ::tagval::Entry<Owner, #FuncName __VA_OPT__(, ) __VA_ARGS__> {}; \
[[maybe_unused]] [[nodiscard]] static auto const& FuncName() { \
return base_t::template value<TypeName>(); \
}
Compile-time entry.
Definition entry.hpp:33

◆ TAGVAL_ENTRY_AS

#define TAGVAL_ENTRY_AS (   Owner,
  TypeName,
  FuncName,
  Code,
  ... 
)
Value:
struct TypeName : ::tagval::Entry<Owner, Code __VA_OPT__(, ) __VA_ARGS__> {}; \
[[maybe_unused]] [[nodiscard]] static auto const& FuncName() { \
return base_t::template value<TypeName>(); \
}

◆ TAGVAL_EXTERN_ENTRY

#define TAGVAL_EXTERN_ENTRY (   Owner,
  TypeName,
  FuncName,
  ... 
)
Value:
struct TypeName : ::tagval::Entry<Owner, #FuncName __VA_OPT__(, ) __VA_ARGS__> {}; \
[[maybe_unused]] [[nodiscard]] inline auto const& FuncName() { \
return Owner::template value<TypeName>(); \
} \
/* NOLINTNEXTLINE(readability-identifier-naming) */ \
TAGVAL_DETAIL_USED [[maybe_unused]] inline const bool TypeName##_registered_ = [] { \
::tagval::OpenEndedRegistry<Owner>::add(&::tagval::metadata_v<TypeName>); \
return true; \
}()
#define TAGVAL_DETAIL_USED
Definition macros.hpp:27

◆ TAGVAL_EXTERN_ENTRY_AS

#define TAGVAL_EXTERN_ENTRY_AS (   Owner,
  TypeName,
  FuncName,
  Code,
  ... 
)
Value:
struct TypeName : ::tagval::Entry<Owner, Code __VA_OPT__(, ) __VA_ARGS__> {}; \
[[maybe_unused]] [[nodiscard]] inline auto const& FuncName() { \
return Owner::template value<TypeName>(); \
} \
/* NOLINTNEXTLINE(readability-identifier-naming) */ \
TAGVAL_DETAIL_USED [[maybe_unused]] inline const bool TypeName##_registered_ = [] { \
::tagval::OpenEndedRegistry<Owner>::add(&::tagval::metadata_v<TypeName>); \
return true; \
}()

◆ TAGVAL_DETAIL_PASTE2

#define TAGVAL_DETAIL_PASTE2 (   a,
 
)    a##b

◆ TAGVAL_DETAIL_PASTE

#define TAGVAL_DETAIL_PASTE (   a,
 
)    TAGVAL_DETAIL_PASTE2(a, b)

◆ TAGVAL_REGISTER_KIND

#define TAGVAL_REGISTER_KIND (   KindType)
Value:
/* NOLINTNEXTLINE(readability-identifier-naming) */ \
TAGVAL_DETAIL_USED [[maybe_unused]] inline const bool TAGVAL_DETAIL_PASTE( \
tagval_kind_registered_, __LINE__) = [] { \
::tagval::KindRegistry::register_kind<KindType>(); \
return true; \
}()
#define TAGVAL_DETAIL_PASTE(a, b)
Definition macros.hpp:76