diff --git a/include/rfl/internal/cpp20/num_fields.hpp b/include/rfl/internal/cpp20/num_fields.hpp index 3864336e..42c6c055 100644 --- a/include/rfl/internal/cpp20/num_fields.hpp +++ b/include/rfl/internal/cpp20/num_fields.hpp @@ -78,12 +78,22 @@ struct any { constexpr operator T() const noexcept; }; +/// Like `any`, but never converts to `T` itself, so that a single argument cannot select `T`'s +/// copy or move constructor instead of aggregate-initializing its first field. +template +struct any_but { + any_but(std::size_t); + template + requires(!std::is_same_v, std::remove_cv_t>) + constexpr operator U() const noexcept; +}; + template struct CountFieldsHelper { template static consteval bool constructible() { return [](std::index_sequence) { - return requires { T{any(is)...}; }; + return std::is_constructible_v(is))...>; }(std::make_index_sequence()); }