morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
reflected_member.hpp File Reference

The value glaze reads and writes under a reflected key. More...

#include <cstddef>
#include <glaze/glaze.hpp>
#include <type_traits>

Go to the source code of this file.

Functions

template<std::size_t I, typename T>
constexpr decltype(auto) morph::detail::reflectedMember (T &object)
 The value glaze reads and writes under glz::reflect<T>::keys[I].

Detailed Description

The value glaze reads and writes under a reflected key.

Definition in file reflected_member.hpp.

Function Documentation

◆ reflectedMember()

template<std::size_t I, typename T>
decltype(auto) morph::detail::reflectedMember ( T & object)
nodiscardconstexpr

The value glaze reads and writes under glz::reflect<T>::keys[I].

glz::reflect<T> follows a glz::meta<T> when one exists, and that meta may omit, rename, reorder or compute members. glz::to_tie always follows the aggregate's declaration order. Indexing one with the other's I hands one member's value to another member's name — a hidden member offered under a public key, or a key bound to a value of a different type. This reads the value from the same source the key comes from: the declaration-order tie for a type glaze reflects by itself, the meta's I-th value otherwise.

For a member of the object, the result is a reference to it, const when object is. A meta entry that computes its value (a lambda, a glaze wrapper such as glz::quoted_num) yields whatever glaze's get_member yields for it, which may be a value rather than a reference.

Template Parameters
IIndex of the key in glz::reflect<std::remove_cvref_t<T>>::keys.
TThe object's type, possibly const-qualified; a type glaze reflects by itself or one with a glz::meta object.
Parameters
objectThe object to read from; it must outlive the returned reference.
Returns
The value glaze reads and writes under key I of object.

Definition at line 36 of file reflected_member.hpp.