Overview / Foundation

meta

Compile-time type description (structs, enums, flags), header-only, with no RTTI and no allocation.

Always compiled: part of the core build.Include #include <ethereal/cpp/meta/meta.hpp>

meta.hpp

#include <ethereal/cpp/meta/meta.hpp>

Umbrella header of the compile-time part of the Meta module.

Header only, a leaf, C++17, standard library only, and zero cost at run time.

Five specs used to describe, each one with its own macro, how the fields of a struct map to names. That meant five syntaxes to learn and five places for the same bug. Meta is the only one. See the module README for what it guarantees and what it does not.

The TypeId and the 'Fields( id )' registry have state at run time. They live in 'meta_runtime.hpp' and are included on their own. See the note in that header.

meta_attributes.hpp

#include <ethereal/cpp/meta/meta_attributes.hpp>

Field attributes of the Meta module, and the flat tuple that holds them.

'Sensitive' is the one that pays for itself: one annotation, and Config masks the field when dumping, CrashReport scrubs it, Telemetry refuses to emit it and Log redacts it. The consumers ask for it by type, at compile time.

struct

STuple

Ethereal::Meta#
C++
template < typename... T >
struct   STuple : Detail::STupleImpl< std::index_sequence_for< T... >, T... >
{
    /// @brief  The implementation base.
    using Base = Detail::STupleImpl< std::index_sequence_for< T... >, T... >;

    /// @brief  Number of elements.
    static constexpr std::size_t kSize = sizeof...( T );

    /// @brief  Builds the tuple from its elements.
    ///
    constexpr explicit STuple( T... tValues ) noexcept
        : Base( tValues... )
    {
    }
};
function

decltype

Ethereal::Meta#
template < std::size_t I, typename... T > constexpr decltype( auto ) Get( const STuple< T... > & Tup ) noexcept

The element I. The deduction through the base picks the right leaf.

enum

EAttributeKind

Ethereal::Meta#
C++
enum class   EAttributeKind : std::uint32_t
{
    /// @brief  No attribute.
    eNone            = 0u,

    /// @brief  Meta::Range.
    eRange            = 1u << 0,

    /// @brief  Meta::Default.
    eDefault        = 1u << 1,

    /// @brief  Meta::Description.
    eDescription    = 1u << 2,

    /// @brief  Meta::Sensitive.
    eSensitive        = 1u << 3,

    /// @brief  Meta::Optional.
    eOptional        = 1u << 4,

    /// @brief  Meta::Skip.
    eSkip            = 1u << 5,

    /// @brief  Meta::Alias.
    eAlias            = 1u << 6,

    /// @brief  Meta::Version.
    eVersion        = 1u << 7,

    /// @brief  Meta::Unit.
    eUnit            = 1u << 8,

    /// @brief  An attribute defined by the integrator.
    eCustom            = 1u << 31
};
struct

SAttribute

Ethereal::Meta#
C++
struct   SAttribute
{
    /// @brief  Kind bit of the attribute.
    static constexpr std::uint32_t kKindMask = static_cast< std::uint32_t >( EAttributeKind::eCustom );
};

The base of every attribute.

A custom attribute derives from this and gets the kind 'eCustom' by default. This base is how ETL_META_FIELD tells an attribute from the explicit field name. A type that does not derive from it is rejected with a sentence, not with a template backtrace.

struct

Range

Ethereal::Meta#
C++
template < typename T >
struct   Range : SAttribute
{
    /// @brief  Kind bit of the attribute.
    static constexpr std::uint32_t kKindMask = static_cast< std::uint32_t >( EAttributeKind::eRange );

    /// @brief  Lowest valid value.
    T    tMin;

    /// @brief  Highest valid value.
    T    tMax;

    /// @brief  Builds the range from its two ends.
    ///
    constexpr Range( const T tMinimum, const T tMaximum ) noexcept : tMin( tMinimum ), tMax( tMaximum ) {}
};

The valid range of a numeric field.

function

Range

Ethereal::Meta#
template < typename A, typename B > Range( A, B ) -> Range< std::common_type_t< A, B > >;

'Range( 0, 1.5 )' mixes types. The common type resolves it.

struct

Default

Ethereal::Meta#
C++
template < typename T >
struct   Default : SAttribute
{
    /// @brief  Kind bit of the attribute.
    static constexpr std::uint32_t kKindMask = static_cast< std::uint32_t >( EAttributeKind::eDefault );

    /// @brief  The default value.
    T    tValue;

    /// @brief  Builds the attribute from the default value.
    ///
    constexpr explicit Default( const T tDefault ) noexcept : tValue( tDefault ) {}
};

The default value of the field.

struct

Description

Ethereal::Meta#
C++
struct   Description : SAttribute
{
    /// @brief  Kind bit of the attribute.
    static constexpr std::uint32_t kKindMask = static_cast< std::uint32_t >( EAttributeKind::eDescription );

    /// @brief  The description.
    std::string_view    sText;

    /// @brief  Builds the attribute from the text.
    ///
    constexpr explicit Description( const std::string_view s ) noexcept : sText( s ) {}
};

A sentence that describes the field, for help and generated documentation.

struct

Sensitive

Ethereal::Meta#
C++
struct   Sensitive : SAttribute
{
    /// @brief  Kind bit of the attribute.
    static constexpr std::uint32_t kKindMask = static_cast< std::uint32_t >( EAttributeKind::eSensitive );
};

The field is a secret: mask it, scrub it, never emit it.

struct

Optional

Ethereal::Meta#
C++
struct   Optional : SAttribute
{
    /// @brief  Kind bit of the attribute.
    static constexpr std::uint32_t kKindMask = static_cast< std::uint32_t >( EAttributeKind::eOptional );
};

The field may be missing in the source without an error.

struct

Skip

Ethereal::Meta#
C++
struct   Skip : SAttribute
{
    /// @brief  Kind bit of the attribute.
    static constexpr std::uint32_t kKindMask = static_cast< std::uint32_t >( EAttributeKind::eSkip );
};

The consumers ignore the field (not bound, not serialized).

struct

Alias

Ethereal::Meta#
C++
struct   Alias : SAttribute
{
    /// @brief  Kind bit of the attribute.
    static constexpr std::uint32_t kKindMask = static_cast< std::uint32_t >( EAttributeKind::eAlias );

    /// @brief  The alternative name.
    std::string_view    sName;

    /// @brief  Builds the attribute from the alternative name.
    ///
    constexpr explicit Alias( const std::string_view s ) noexcept : sName( s ) {}
};

An alternative name accepted on reading (renames that do not break old files).

struct

Version

Ethereal::Meta#
C++
struct   Version : SAttribute
{
    /// @brief  Kind bit of the attribute.
    static constexpr std::uint32_t kKindMask = static_cast< std::uint32_t >( EAttributeKind::eVersion );

    /// @brief  First schema version with the field.
    std::uint32_t    uSince;

    /// @brief  Builds the attribute from the version.
    ///
    constexpr explicit Version( const std::uint32_t u ) noexcept : uSince( u ) {}
};

The schema version in which the field appeared.

struct

Unit

Ethereal::Meta#
C++
struct   Unit : SAttribute
{
    /// @brief  Kind bit of the attribute.
    static constexpr std::uint32_t kKindMask = static_cast< std::uint32_t >( EAttributeKind::eUnit );

    /// @brief  The unit symbol.
    std::string_view    sSymbol;

    /// @brief  Builds the attribute from the symbol.
    ///
    constexpr explicit Unit( const std::string_view s ) noexcept : sSymbol( s ) {}
};

The unit of the value ("ms", "bytes"), for display and conversion.

function

noexcept

Ethereal::Meta#
template < typename A, typename... T > constexpr std::bool_constant< ( std::is_same_v< A, T > || ... ) > Has( const STuple< T... > & ) noexcept

The attribute set has one of type exactly A.

function

noexcept

Ethereal::Meta#
template < typename... T > constexpr std::integral_constant< std::uint32_t, ( 0u | ... | T::kKindMask ) > KindMask( const STuple< T... > & ) noexcept

The kinds present, or'ed together.

function

GetAttribute

Ethereal::Meta#
template < typename A, typename... T > constexpr const A & GetAttribute( const STuple< T... > & Tup ) noexcept
function

decltype

Ethereal::Meta#
template < EAttributeKind KKind, typename... T > constexpr decltype( auto ) GetAttributeByKind( const STuple< T... > & Tup ) noexcept

The first attribute of kind KKind (for the template ones: Range, Default).

meta_enum.hpp

#include <ethereal/cpp/meta/meta_enum.hpp>

Enum description of the Meta module: name to value and back, the count, and flag enums.

Every consumer of this module needs this, and today each one writes its own by hand. Here it is written once:

enum class ELogLevel { Trace, Debug, Info, Warn, Error }; ETL_META_ENUM( ELogLevel, Trace, Debug, Info, Warn, Error );

Meta::Name( ELogLevel::Warn ) -> "Warn" Meta::Parse( "Warn", &eLevel ) -> true Meta::Count< ELogLevel >() -> 5

Invoke it in the namespace of the enum, for the same reason as ETL_META_DESCRIBE (ADL). That is also what lets ETL_META_FLAGS define the bitwise operators where ADL finds them.

Limit: 125 enumerators per description. MSVC rejects macros with more than 127 parameters (C1112), and the count needs two more. See 'meta_macros.hpp'.

const

IsDescribedEnum

Ethereal::Meta#
template < typename E > inline constexpr bool IsDescribedEnum = Detail::SIsDescribedEnum< E >::value;
function

Count

Ethereal::Meta#
template < typename E > constexpr std::size_t Count() noexcept

Number of enumerators in the description.

function

ValueAt

Ethereal::Meta#
template < typename E > constexpr E ValueAt( const std::size_t i ) noexcept

The enumerator at position i of the description.

function

NameAt

Ethereal::Meta#
template < typename E > constexpr std::string_view NameAt( const std::size_t i ) noexcept

The name at position i of the description.

function

Name

Ethereal::Meta#
template < typename E > constexpr std::string_view Name( const E e ) noexcept

The name of the value, or empty when the value is not a described enumerator.

In a flag enum, a combination ('A|B') is not an enumerator. Use FormatFlags for it.

function

Parse

Ethereal::Meta#
template < typename E > constexpr bool Parse( const std::string_view sName, E * const pOut ) noexcept

Reads a name back into the value. Exact and case sensitive.

Compares the length before any byte: a name is only compared character by character when the size already matches, and with names of different sizes that is a single integer comparison per candidate.

sName
The enumerator name.
pOut
Receives the value. May be null.
false when no enumerator has that name. pOut is left untouched.
function

IsFlags

Ethereal::Meta#
template < typename E > constexpr bool IsFlags() noexcept

The enum was described with ETL_META_FLAGS.

function

ParseFlags

Ethereal::Meta#
template < typename E > constexpr bool ParseFlags( const std::string_view sText, E * const pOut ) noexcept

Reads "A|B|C" into a flag value. Spaces around each name are ignored.

sText
The text to read.
pOut
Receives the value. May be null.
false when some name does not exist. pOut is left untouched.
function

FormatFlags

Ethereal::Meta#
template < typename E > constexpr bool FormatFlags( const E e, char * const pOut, const std::size_t uCap, std::size_t * const pWritten ) noexcept

Writes a flag value as "A|B|C" into pOut.

Walks the enumerators in description order and writes each one whose bits are all set and that still covers some bit not yet written. Bits that no enumerator covers come out at the end in hexadecimal ("A|0x40"), so formatting never loses information silently. Zero comes out as the name of the enumerator that is zero, or "0" when there is none.

e
The value.
pOut
The output buffer.
uCap
Size of pOut, with the terminator.
pWritten
Receives the characters written, without the terminator.
false when uCap is not enough. pOut keeps what fit, terminated.

meta_macros.hpp

#include <ethereal/cpp/meta/meta_macros.hpp>

Preprocessor tools of the Meta module.

Generated by 'tools/gen_meta_macros.py'. Do not edit by hand, run the generator again.

Argument count and a FOR_EACH that goes up to 125 arguments.

Why 125: MSVC rejects a macro with more than 127 formal parameters (C1112, measured). The counter needs the limit plus 2, so 125 is the maximum. Only ETL_META_ENUM counts its arguments. The fields of ETL_META_DESCRIBE go to a function call and have no preprocessor limit (an invocation with 300 arguments passed on MSVC).

The 'EXPAND(x)' idiom is required. MSVC without '/Zc:preprocessor' passes '__VA_ARGS__' as a single argument to the next macro. Wrapping the invocation in 'EXPAND' forces a new scan after the substitution, and only then the commas split the arguments. Without it the count is always 1 on MSVC and 1..N on the others, a bug that only shows up on the compiler of the integrator.

macro

ETL_META_EXPAND

#
#define ETL_META_EXPAND( x ) x

Forces a new scan of the argument. See the EXPAND note above.

macro

ETL_META_CAT_I

#
#define ETL_META_CAT_I( a, b ) a ## b

Token pasting, with the arguments expanded first.

macro

ETL_META_STR_I

#
#define ETL_META_STR_I( x ) #x

Stringizing, with the argument expanded first.

macro

ETL_META_MAX_ARGS

#
#define ETL_META_MAX_ARGS 125

The largest number of arguments the Meta macros accept.

macro

ETL_META_ARG_N

#
#define ETL_META_ARG_N( _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37,

Selects the argument at position MAX+1, which is the count when the list is followed by the descending ladder.

macro

ETL_META_NARGS

#
#define ETL_META_NARGS( ... ) ETL_META_EXPAND( ETL_META_ARG_N( __VA_ARGS__, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101,

Number of arguments (1..125). Zero arguments is not supported.

macro

ETL_META_ONE_OR_N

#
#define ETL_META_ONE_OR_N( ... ) ETL_META_EXPAND( ETL_META_ARG_N( __VA_ARGS__, ETL_META_MANY, ETL_META_MANY, ETL_META_MANY, ETL_META_MANY, ETL_META_MANY, ETL_META_MANY, ETL_META_MANY, ETL_META_MANY, E

'1' when there is exactly one argument, 'ETL_META_MANY' when there are more. Dispatches macros with an optional part without '__VA_OPT__' (C++20).

The returned token is pasted, and ETL_META_CAT expands the arguments before pasting. A short token such as 'N' would be replaced by any '#define N' of the integrator, and the paste would give a name that does not exist. That is why it has the module prefix, and why 'ETL_META_MANY' can never be a macro.

macro

ETL_META_FE_1

#
#define ETL_META_FE_1( M, D, x ) M( D, x )

Comma separated FOR_EACH: M( D, x1 ), M( D, x2 ), ...

macro

ETL_META_FOR_EACH

#
#define ETL_META_FOR_EACH( M, D, ... ) ETL_META_EXPAND( ETL_META_CAT( ETL_META_FE_, ETL_META_NARGS( __VA_ARGS__ ) )( M, D, __VA_ARGS__ ) )

Applies 'M( D, x )' to each argument, separated by commas.

meta_runtime.hpp

#include <ethereal/cpp/meta/meta_runtime.hpp>

The part of the Meta module that has state at run time: the dense TypeId and the type erased view of the fields (the registry that 'Fields( id )' looks up).

It is not included by 'meta.hpp', on purpose. The rest of Meta is compile time only and costs nothing at run time. This part needs an atomic counter and a table, and '<atomic>' alone costs about 90 ms of compile time per translation unit on MSVC (measured). Code that needs ids or the boundary without templates (ECS, Event, the C layers) includes this header. Code that only describes structs and enums does not pay for it.

The TypeId is dense and assigned on first use. A dense integer, unique per type and fixed at compile time across translation units, does not exist in portable C++: each unit compiles alone and none knows how many types the others numbered. What is delivered is what the consumers need (ECS, Event): dense from zero, stable for the life of the process, usable as a vector index. The same number between two runs is not guaranteed. For a key that is stable across runs and binaries, use TypeName.

struct

SFieldDescriptor

Ethereal::Meta#
C++
struct   SFieldDescriptor
{
    /// @brief  Field name.
    std::string_view    sName;

    /// @brief  TypeId of the member type.
    std::uint32_t        iTypeId = 0u;

    /// @brief  Offset inside the struct, or FIELD_OFFSET_UNKNOWN.
    std::uint16_t        iOffset = 0u;

    /// @brief  Size of the member, or FIELD_OFFSET_UNKNOWN.
    std::uint16_t        iSize = 0u;

    /// @brief  Attribute kinds present (see @ref EAttributeKind).
    std::uint32_t        iAttributeMask = 0u;
};

A field seen without templates. POD, queryable at run time.

The offset and the size are 16 bits, as the spec asks. A struct larger than 64 KiB has the fields past that limit marked with FIELD_OFFSET_UNKNOWN, never with a truncated offset.

const

FIELD_OFFSET_UNKNOWN

Ethereal::Meta#
inline constexpr std::uint16_t FIELD_OFFSET_UNKNOWN = 0xFFFFu;

The offset (or size) of a field that does not fit in 16 bits.

struct

SFieldList

Ethereal::Meta#
C++
struct   SFieldList
{
    /// @brief  First descriptor.
    const SFieldDescriptor *    pData = nullptr;

    /// @brief  Number of descriptors.
    std::size_t                    uCount = 0u;

    /// @brief  Iterator to the first descriptor.
    ///
    constexpr const SFieldDescriptor * begin() const noexcept            { return pData; }

    /// @brief  Iterator past the last descriptor.
    ///
    constexpr const SFieldDescriptor * end() const noexcept                { return pData + uCount; }

    /// @brief  Number of descriptors.
    ///
    constexpr std::size_t size() const noexcept                            { return uCount; }

    /// @brief  The list is empty.
    ///
    constexpr bool empty() const noexcept                                { return uCount == 0u; }

    /// @brief  Descriptor at position i, unchecked.
    ///
    constexpr const SFieldDescriptor & operator[]( std::size_t i ) const noexcept { return pData[ i ]; }
};

A list of field descriptors (C++17 has no 'std::span').

const

TYPE_REGISTRY_CAPACITY

Ethereal::Meta#
inline constexpr std::uint32_t TYPE_REGISTRY_CAPACITY = 4096u;

Number of types the registry holds. Types with an id above this still have an id, but Fields( std::uint32_t ) returns an empty list for them.

function

TypeId

Ethereal::Meta#
template < typename T > std::uint32_t TypeId() noexcept;

Forward declaration. See the definition below.

function

TypeId

Ethereal::Meta#
template < typename T > std::uint32_t TypeId() noexcept
function

Fields

Ethereal::Meta#
template < typename T > SFieldList Fields() noexcept

The fields of a described type, seen without templates.

function

Fields

Ethereal::Meta#
inline SFieldList Fields( const std::uint32_t iTypeId ) noexcept

The fields of the type with this id. Empty list for a type that is not described, an unknown id, or an id above TYPE_REGISTRY_CAPACITY.

iTypeId
The id, from TypeId.
The field list.

meta_service.hpp

#include <ethereal/cpp/meta/meta_service.hpp>

Service description of the Meta module, from which the RPC builds its dispatch table.

Usage:

ETL_META_SERVICE( CUserService, ETL_META_METHOD( GetUser, "get_user" ), ETL_META_METHOD( CreateUser ) ); // derived name: "create_user"

The method id is stable across builds: it is the FNV-1a hash of the wire name, not the declaration order or the C++ identifier. Renaming the method in C++ while keeping the wire name keeps the id, and so does reordering the list. Two equal hashes in the same service are rejected at compile time, with the service named.

An overloaded method cannot be described, since '&CUserService::GetUser' would be ambiguous. An RPC service with the same name for two signatures is badly designed anyway, because the wire name is the same.

struct

STypeList

Ethereal::Meta#
C++
template < typename... T >
struct   STypeList
{
    /// @brief  Number of types.
    static constexpr std::size_t kSize = sizeof...( T );
};

A list of types, for the parameters of a method.

struct

SMethod

Ethereal::Meta#
C++
template < typename TFn, std::size_t NName >
struct   SMethod
{
    /// @brief  Traits of the member function pointer.
    using Traits     = Detail::SMemberFnTraits< TFn >;

    /// @brief  The return type.
    using ReturnType = typename Traits::ReturnType;

    /// @brief  The parameter types.
    using Params     = typename Traits::Params;

    /// @brief  Number of parameters.
    static constexpr std::size_t kArity = Traits::kArity;

    /// @brief  Pointer to the method.
    TFn                        pMethod;

    /// @brief  Wire name.
    SFixedString< NName >    Name;

    /// @brief  Stable id, the FNV-1a hash of the wire name.
    std::uint32_t            uId;

    /// @brief  View over the wire name.
    ///
    constexpr std::string_view NameView() const noexcept    { return Name.View(); }
};
const

IsService

Ethereal::Meta#
template < typename T > inline constexpr bool IsService = !std::is_same_v< Detail::ServiceDescriptorOf< std::remove_cv_t< T > >, Detail::SNotDescribedService >;
function

MethodCount

Ethereal::Meta#
template < typename S > constexpr std::size_t MethodCount() noexcept

Number of methods of the described service.

function

ForEachMethod

Ethereal::Meta#
template < typename S, typename TFn > ETL_META_FORCEINLINE constexpr void ForEachMethod( TFn && Visit ) noexcept

Visits each method: 'Visit( std::string_view sName, std::uint32_t uId, const SMethod<...>& Method )'.

Visit
The visitor.
function

MethodIndexById

Ethereal::Meta#
template < typename S > constexpr std::size_t MethodIndexById( const std::uint32_t uId ) noexcept

Position of the method with id uId, or MethodCount when there is none.

function

MethodId

Ethereal::Meta#
constexpr std::uint32_t MethodId( const std::string_view sWireName ) noexcept

The id of a wire name. The same computation the descriptor does.

meta_string.hpp

#include <ethereal/cpp/meta/meta_string.hpp>

Compile-time text of the Meta module.

A fixed size string that lives inside a 'constexpr' descriptor, the field name derived from the identifier, the stable hash of the method names, and the type name normalized across compilers.

Everything here is C++17 and uses only the standard library. Meta is a leaf: it includes no other Ethereal header, so any module can use it without a cycle.

struct

SFixedString

Ethereal::Meta#
C++
template < std::size_t NCap >
struct   SFixedString
{
    static_assert( NCap >= 1, "Meta: SFixedString needs room for at least the terminator." );

    /// @brief  The characters, terminated.
    char            aData[ NCap ] = {};

    /// @brief  Number of characters, without the terminator.
    std::size_t        uLen = 0;

    /// @brief  View over the characters.
    ///
    constexpr std::string_view View() const noexcept    { return std::string_view( aData, uLen ); }

    /// @brief  Number of characters, without the terminator.
    ///
    constexpr std::size_t Size() const noexcept            { return uLen; }
};

A fixed size string, built at compile time.

This is what lets the names live inside the descriptor. A derived name ('iPort' -> "port") does not exist as a literal anywhere, it has to be computed and stored. Stored here, inside a 'static constexpr' object, it goes to '.rodata' and the returned 'std::string_view' points to a stable address.

NCap
The capacity, counting the terminator.
function

TypeName

Ethereal::Meta#
template < typename T > constexpr std::string_view TypeName() noexcept

meta_struct.hpp

#include <ethereal/cpp/meta/meta_struct.hpp>

Struct description of the Meta module: ETL_META_DESCRIBE, ETL_META_FIELD and the iteration over the fields.

Zero cost at run time. The descriptor is a 'static constexpr' object (it goes to '.rodata', with no static initializer), and ForEachField is a pack expansion the compiler unrolls: walking the fields generates the same code as writing each access by hand. No RTTI, 'typeid', map or memory allocation.

Invoke it in the same namespace as the type. The descriptor is found by ADL, and ADL only looks in the namespaces associated with the type. To describe a third party struct that cannot be edited, reopen its namespace and invoke it there:

namespace vendor { ETL_META_DESCRIBE( SPacket, ETL_META_FIELD( len ) ); }

For a type in the global namespace, invoke it in the global namespace. A type with a comma in its name (a template with two arguments) goes through a 'using' first.

struct

SField

Ethereal::Meta#
C++
template < typename TClass, typename TMember, std::size_t NName, typename... TAttrs >
struct   SField
{
    /// @brief  The struct the member belongs to.
    using ClassType     = TClass;

    /// @brief  The type of the member.
    using MemberType    = TMember;

    /// @brief  The tuple type of the attributes.
    using AttributeSet  = STuple< TAttrs... >;

    /// @brief  Pointer to the member.
    TMember TClass::*        pMember;

    /// @brief  Field name, derived or explicit.
    SFixedString< NName >    Name;

    /// @brief  Offset of the member inside the struct.
    std::size_t                uOffset;

    /// @brief  The attributes.
    STuple< TAttrs... >        Attributes;

    /// @brief  The attribute kinds present, or'ed together (see @ref EAttributeKind).
    static constexpr std::uint32_t kAttributeMask = ( 0u | ... | TAttrs::kKindMask );

    /// @brief  View over the field name.
    ///
    constexpr std::string_view NameView() const noexcept    { return Name.View(); }

    /// @brief  The field has an attribute of type exactly @p A. Compile-time constant.
    ///
    template < typename A >
    static constexpr bool Has() noexcept                    { return ( std::is_same_v< A, TAttrs > || ... ); }

    /// @brief  The field has an attribute of kind @p K. Compile-time constant.
    ///
    static constexpr bool HasKind( const EAttributeKind K ) noexcept
    {
        return ( kAttributeMask & static_cast< std::uint32_t >( K ) ) != 0u;
    }
};

A described field: the member pointer, the name, the offset and the attributes.

TClass
The struct the member belongs to.
TMember
The type of the member.
NName
Capacity of the name, with the terminator.
TAttrs
Types of the attributes, in the order they were written.
const

IsDescribed

Ethereal::Meta#
template < typename T > inline constexpr bool IsDescribed = !std::is_same_v< Detail::DescriptorOf< std::remove_cv_t< T > >, Detail::SNotDescribed >;
function

FieldCount

Ethereal::Meta#
template < typename T > constexpr std::size_t FieldCount() noexcept

Number of fields of the described type.

function

decltype

Ethereal::Meta#
template < typename T, std::size_t I > constexpr decltype( auto ) FieldAt() noexcept

The whole descriptor of field I (member pointer, name, attributes).

function

FieldName

Ethereal::Meta#
template < typename T, std::size_t I > constexpr std::string_view FieldName() noexcept

The name of field I.

function

decltype

Ethereal::Meta#
template < std::size_t I, typename T > constexpr decltype( auto ) GetField( T & Object ) noexcept

The value of field I of Object, by reference.

function

ForEachField

Ethereal::Meta#
template < typename T, typename TFn > ETL_META_FORCEINLINE constexpr void ForEachField( TFn && Visit ) noexcept

Visits each field of the type: 'Visit( std::string_view sName, const SField<...>& Field )'.

The field descriptor carries 'pMember', 'Attributes', 'uOffset' and 'MemberType'. To ask for attributes at compile time inside the visitor: 'std::decay_t<decltype( Field )>::template Has<Meta::Sensitive>()'.

Visit
The visitor.
function

ForEachField

Ethereal::Meta#
template < typename T, typename TFn > ETL_META_FORCEINLINE constexpr void ForEachField( T & Object, TFn && Visit ) noexcept

Visits each field of an object: 'Visit( std::string_view sName, auto& Value, const auto& Attributes )'.

With a 'const' object the value arrives 'const'. Ask for the attributes with ETL_META_HAS( Attributes, Meta::Sensitive ) inside 'if constexpr'.

Object
The object to visit.
Visit
The visitor.
function

FieldIndex

Ethereal::Meta#
template < typename T > constexpr std::size_t FieldIndex( const std::string_view sName ) noexcept

Position of the field named sName, or FieldCount when there is none.

function

HasField

Ethereal::Meta#
template < typename T > constexpr bool HasField( const std::string_view sName ) noexcept

The described type has a field named sName. Compile-time constant.

meta_traits.hpp

#include <ethereal/cpp/meta/meta_traits.hpp>

Category traits of the Meta module.

The traits the consumers branch on: integral, enum, container, string, optional, described and trivially serializable.

There is no '<array>' here. The 'std::array' trait detects the shape (value_type, tuple_size, data() and a size with no padding) instead of naming the type. Naming it would require '<array>', which costs about 230 ms per translation unit on MSVC, more than the whole budget of the spec. Code that uses a 'std::array' has already included '<array>', and then the specialized 'tuple_size' is visible.

const

IsIntegral

Ethereal::Meta#
template < typename T > inline constexpr bool IsIntegral = std::is_integral_v< T >;
const

IsEnum

Ethereal::Meta#
template < typename T > inline constexpr bool IsEnum = std::is_enum_v< T >;

The type is an enum.

const

IsContainer

Ethereal::Meta#
template < typename T > inline constexpr bool IsContainer = Detail::SIsContainer< T >::value;

The type is a container (begin, end and size).

const

IsOptionalLike

Ethereal::Meta#
template < typename T > inline constexpr bool IsOptionalLike = Detail::SIsOptionalLike< T >::value;

The type behaves like an optional (has_value and dereference).

const

IsStringLike

Ethereal::Meta#
template < typename T > inline constexpr bool IsStringLike = std::is_convertible_v< const T &, std::string_view >;

The type converts to 'std::string_view' (std::string, literals, 'const char*').

function

IsTriviallySerializable

Ethereal::Meta#
template < typename T > inline constexpr bool IsTriviallySerializable = Detail::TriviallySerializable< std::remove_cv_t< T > >();