Код: Выделить всё
struct Particle
{
float scale;
float opacity;
float rotation;
};
Код: Выделить всё
static_assert(indexOf() == 0);
static_assert(indexOf() == 1);
static_assert(indexOf() == 2);
Код: Выделить всё
template
consteval int indexOf()
{
using ClassType = typename PMTraits::ClassType;
constexpr ClassType obj{};
std::size_t result = -1;
[&](std::index_sequence)
{
(...,
(
( static_cast(&(boost::pfr::get(obj)))
== static_cast(&(obj.*PM)) )
? (result = Is) : 0
)
);
}(std::make_index_sequence{});
return result;
}
Есть ли лучший способ сделать это, чтобы (1) не требовало создания объекта во время компиляции и/или (2) было бы более эффективно компилировать?
Подробнее здесь: https://stackoverflow.com/questions/797 ... reating-an
Мобильная версия