File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments