Skip to content

Commit 025c3ae

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

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Framework/Foundation/include/Framework/StructToTuple.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,12 @@ 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+
} else {
141142
return brace_constructible_size<T>(Members..., UniversalType{});
143+
}
142144
}
143145
#else
144146
template <typename T>
@@ -282,6 +284,7 @@ auto homogeneous_apply_refs(L l, T&& object)
282284
using type = std::decay_t<T>;
283285
constexpr int nesting = B ? 1 : 0;
284286
constexpr unsigned long numElements = brace_constructible_size<type>() - nesting;
287+
static_assert(numElements < 99, "Too many elements in the struct");
285288
// clang-format off
286289
if DPL_HOMOGENEOUS_APPLY_ENTRY (9, 9)
287290
else if DPL_HOMOGENEOUS_APPLY_ENTRY (9, 8)

0 commit comments

Comments
 (0)