Skip to content

Commit a643e97

Browse files
committed
DPL: make sure homogeneous_apply_ref complains when we are missing an explicit constructor
1 parent 66de309 commit a643e97

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Framework/Foundation/include/Framework/StructToTuple.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,13 @@ struct UniversalType {
135135
template <typename T>
136136
consteval auto brace_constructible_size(auto... Members)
137137
{
138-
if constexpr (requires { T{Members...}; } == false)
138+
if constexpr (requires { T{Members...}; } == false) {
139+
static_assert(sizeof...(Members) != 0, "You need to make sure that you have implicit constructors or that you call the explicit constructor correctly.");
139140
return sizeof...(Members) - 1;
140-
else
141+
}
142+
else {
141143
return brace_constructible_size<T>(Members..., UniversalType{});
144+
}
142145
}
143146
#else
144147
template <typename T>
@@ -282,6 +285,7 @@ auto homogeneous_apply_refs(L l, T&& object)
282285
using type = std::decay_t<T>;
283286
constexpr int nesting = B ? 1 : 0;
284287
constexpr unsigned long numElements = brace_constructible_size<type>() - nesting;
288+
static_assert(numElements < 99, "Too many elements in the struct");
285289
// clang-format off
286290
if DPL_HOMOGENEOUS_APPLY_ENTRY (9, 9)
287291
else if DPL_HOMOGENEOUS_APPLY_ENTRY (9, 8)

0 commit comments

Comments
 (0)