Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glz::for_each_field #1497

Merged
merged 3 commits into from
Dec 14, 2024
Merged

glz::for_each_field #1497

merged 3 commits into from
Dec 14, 2024

Conversation

stephenberry
Copy link
Owner

Adds glz::for_each_field for reflected and meta types.

struct test_type {
   int32_t int1{};
   int64_t int2{};
};

suite reflect_test_type = [] {
   static_assert(glz::reflect<test_type>::size == 2);
   static_assert(glz::reflect<test_type>::keys[0] == "int1");
   
   "for_each_field"_test = [] {
      test_type var{42, 43};
      
      glz::for_each_field(var, [](auto& field) {
          field += 1;
      });
      
      expect(var.int1 == 43);
      expect(var.int2 == 44);
   };
};

@stephenberry stephenberry merged commit 1a183a1 into main Dec 14, 2024
12 checks passed
@stephenberry stephenberry deleted the for_each_field branch December 14, 2024 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant