dimanche 14 mars 2021

C++ static reflection TS: would it support assign/call by name?

There is a C++ Technical Specification on static reflection (current PDF draft and cppreference page) which might move into C++23 or later.

Would it be possible in the current draft (I understand syntax is perhaps not fixed yet) to access struct fields / call class member functions by name?

For instance

struct Test {
  int x;
  int y; 
};

Test foo;

auto meta = reflexpr(foo);  // access meta information about class

some_magic_setter<"x", meta>(foo, 5);  // ??? 

Would this be possible and if yes how ?





Aucun commentaire:

Enregistrer un commentaire