enforce ctx in constructor
Signed-off-by: Faumaray <faumaray@gmail.com>
This commit is contained in:
1 file changed
+8
-1
+8
-1
@@ -17,7 +17,14 @@ template<class T>
|
||||
class Mod : public Base {
|
||||
private:
|
||||
static std::unique_ptr<Base> _vl_factory(const Context& ctx) {
|
||||
return std::make_unique<T>(ctx);
|
||||
if (std::is_constructible_v<T, const Context&>())
|
||||
{
|
||||
return std::make_unique<T>(ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::make_unique<T>();
|
||||
}
|
||||
}
|
||||
|
||||
// Registration only stores a factory pointer — no early T usage.
|
||||
|
||||
Reference in new issue
Block a user