Skip to content

Commit 5879db2

Browse files
Fix GCC template err
1 parent 95bdec7 commit 5879db2

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

ICE/Components/include/NativeScript.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,18 @@ class NativeScript {
6262
double time() const { return m_time; }
6363

6464
// Spawn another entity into this script's scene and return a handle to its root. Forwards to
65-
// Scene::spawn (a model id today; Prefab support lands in T7). A template so a script only
66-
// needs Scene complete (include <Scene.h>) when it actually instantiates.
67-
template<typename... Args>
65+
// Scene::spawn (a model id today; Prefab support lands in T7). A script only needs Scene
66+
// complete (include <Scene.h>) when it actually instantiates.
67+
//
68+
// The SceneT default parameter is deliberate: Scene is only forward-declared here, so
69+
// `scene()->spawn(...)` must not be checked until instantiation. Casting through the template
70+
// parameter SceneT makes the member access dependent, which defers the completeness check to
71+
// the call site under two-phase lookup (GCC/Clang). A plain `template<typename... Args>` left
72+
// `scene()->spawn` non-dependent, so it was checked here -- a hard error on a forward-declared
73+
// Scene (MSVC accepted it; other compilers did not).
74+
template<typename SceneT = Scene, typename... Args>
6875
EntityHandle instantiate(Args&&... args) {
69-
return scene()->spawn(std::forward<Args>(args)...);
76+
return static_cast<SceneT*>(scene())->spawn(std::forward<Args>(args)...);
7077
}
7178

7279
// Mark this entity for destruction. Teardown (onDestroy + component/entity removal) is deferred

0 commit comments

Comments
 (0)