Skip to content

is it a way to serialize field names? #90

@denzor200

Description

@denzor200
#ifdef _STR
#  error _STR already defined
#endif
#define _STR(S) BOOST_METAPARSE_STRING(S){}

struct gps_position
{
    field<int, (name=_STR("degrees"))> degrees;
    field<int, (name=_STR("minutes"))> minutes;
    field<float, (name=_STR("seconds"))> seconds;
};

We need to:

  1. field<T, A> template class, this class is just a wrapper to T with std::reference_wrapper-like(??) iface.
  2. name object with overloaded operator=(std::string_view), and this overloaded operator must be constexpr

This short example:
https://godbolt.org/z/nT4bdrnKc
Interface of field_t<T,A> class is not ideal, but this short example shows that structure with named fields are possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions