GuillaumeDua / CppShelf

Collection of powerfuls - C++ Single-Header Libraries Files
https://guillaumedua.github.io/CppShelf/
MIT License
9 stars 1 forks source link

[ag] csl::ag::views::flatten/_view #245

Open GuillaumeDua opened 1 month ago

GuillaumeDua commented 1 month ago
struct A{ int i; bool b; };
struct B{ char c; }
struct C{ std::string str; A a; B b; };

auto value = C{};
auto view = csl::ag::flatten(value); // or value | csl::ag::views::flatten

static_assert(std::same_as<
   std::remove_cvref_t<decltype(view)>,
   std::tuple<
      std::string&,
      int&, bool&,
      char&
   >
>);

Quick POC: https://godbolt.org/z/YbE6jWYrc