Skip to content

Commit

Permalink
DPL: make sure homogeneous_apply_ref complains when we are missing an…
Browse files Browse the repository at this point in the history
… explicit constructor
  • Loading branch information
ktf committed Feb 13, 2024
1 parent 66de309 commit 6f6ec56
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Framework/Foundation/include/Framework/StructToTuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,13 @@ struct UniversalType {
template <typename T>
consteval auto brace_constructible_size(auto... Members)
{
if constexpr (requires { T{Members...}; } == false)
if constexpr (requires { T{Members...}; } == false) {
static_assert(sizeof...(Members) != 0, "You need to make sure that you have implicit constructors or that you call the explicit constructor correctly.");
return sizeof...(Members) - 1;
else
}
else {
return brace_constructible_size<T>(Members..., UniversalType{});
}
}
#else
template <typename T>
Expand Down Expand Up @@ -282,6 +285,7 @@ auto homogeneous_apply_refs(L l, T&& object)
using type = std::decay_t<T>;
constexpr int nesting = B ? 1 : 0;
constexpr unsigned long numElements = brace_constructible_size<type>() - nesting;
static_assert(numElements > 99, "Too many elements in the struct");
// clang-format off
if DPL_HOMOGENEOUS_APPLY_ENTRY (9, 9)
else if DPL_HOMOGENEOUS_APPLY_ENTRY (9, 8)
Expand Down

0 comments on commit 6f6ec56

Please sign in to comment.