Critique?
#include <iostream>
#include "boost/pfr.hpp"
//////////////////////////////////////////////////////////////////////////////
void print_struct(auto&& s) noexcept
{
using S = std::remove_cvref_t<decltype(s)>;
[&]<auto ...I>(std::index_sequence<I...>) noexcept
{
(
[&]() noexcept
{
if constexpr(I && (I == boost::pfr::tuple_size_v<S> - 1))
{
std::cout << ", " << boost::pfr::get<I>(s) << ')';
}
else if constexpr(I)
{
std::cout << ", " << boost::pfr::get<I>(s);
}
else
{
std::cout << '(' << boost::pfr::get<I>(s);
}
}(),
...
);
}(std::make_index_sequence<boost::pfr::tuple_size_v<S>>());
}
//////////////////////////////////////////////////////////////////////////////
int main()
{
struct
{
int a;
float b;
std::string c;
} s{1, 2.1, "wow"};
print_struct(s);
std::cout << '\n';
return 0;
}
Here's an example.