Zugriff auf templated using innerhalb eines templates aus anderem template
-
Hallo,
Folgender Code:
template <typename T> struct X { template <typename U> using Y = U; }; template <typename T> struct Other { using Type = ::template X<T>::Y<T>; // ??? }; using ForceInstantiation = Other<int>::Type;Wie greife ich bei der kommentierten Zeile auf das nested typedef zu? Ich habe es sowohl mit template, typename, als auch ohne Keyword probiert und keines der drei funktioniert.
http://ideone.com/P78eOy
http://ideone.com/buzrzl
http://ideone.com/wLwukFGruesse
Der Kellerautomat
-
using Type = typename ::X<T>::template Y<T>;
-
Falls du übrigens eine Instantiierung erzwingen willst, nimm eine explizite Instantiierung:
template class Other<int>;X ist kein abhängiger Bezeichner, darum muss dort kein
templatehin, jedoch selbstverständlich für Y, und weil Y auch ein Funktionstemplate (oder seit C++14 auch Variablentemplate) sein könnte, muss da noch eintypenamesein (§14.6/2 gilt für alle abhängigen Namen).
-
Danke. Wer hat sich diesen Mist eigentlich ausgedacht
