У меня есть функция ниже, выполняющая подсчет элементов агрегата (если вам нужна дополнительная информация, посмотрите здесь)
Код: Выделить всё
namespace detail
{
struct filler_t { template constexpr operator T() { return {}; } };
template concept aggregate_type = std::is_aggregate_v;
}
//-------------------------------------------------------------------------
// return member count of an aggregate
template
constexpr auto aggregate_member_count(auto&& ...filler)
{
if constexpr (requires{ T{ filler... }; })
return aggregate_member_count(detail::filler_t{}, filler...);
else
return sizeof...(filler) - 1;
}
Код: Выделить всё
struct A { int a; unsigned b; double c; } sa{1,2,3.};
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/78679882/strange-results-of-aggregate-initialization-and-decomposition[/url]