Skip to content

Trying to read into array multiple times #1548

Answered by stephenberry
VwertIX asked this question in Q&A
Discussion options

You must be logged in to vote

@VwertIX, so I just merged in support (into main) for a new option .append_arrays, which will append to types like std::vector rather than overwriting.

Here are unit tests showing the support. The use in glz::meta is just in case you want to turn on the feature for only select vectors.

struct append_obj
{
   std::vector<std::string> names{};
   std::vector<std::array<int, 2>> arrays{};
};

template <>
struct glz::meta<append_obj>
{
   using T = append_obj;
   static constexpr auto value = object("names", append_arrays<&T::names>, "arrays", append_arrays<&T::arrays>);
};

suite append_arrays_tests = [] {
   "append_arrays vector"_test = [] {
      std::vector<int> v{};
      constexpr glz:…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by stephenberry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants