The following code compiles with g ++, but does not compile with clang.
struct X; template <typename T> struct Traits { typedef typename Traits<T>::Container Container; }; template <> struct Traits<X> { typedef std::vector<X *> Container; }; int main() { Traits<X>::Container container; return EXIT_SUCCESS; }
clang error message:
main.cpp:9:30: error: no type named 'Container' in 'Traits<T>'
Should the compiler evaluate typedef without replacing the template parameter with the actual type? Which compiler is right?
clang: http://coliru.stacked-crooked.com/a/fef7725827074e4f
gcc: http://coliru.stacked-crooked.com/a/79e17031fcabcd83
template <typename T> struct Traits { typedef typename Traits<T>::Container Container; };
it is poorly formed, no diagnostics are required. No T, the above (primary) specialization could lead to a valid code.
T
. - , . . , foo . , .
foo
, , T (.. ) , .
Source: https://habr.com/ru/post/1674233/More articles:Do compilers usually use registers for their "intended" purpose? - assemblyW3 Total Cache launched my site on a mobile phone hosted on Godaddy - htmlCloud functions for Firebase onWrite () always promise time - firebaseMapKit: MKCircle rendering with unwanted artifacts - xcodeMatlab character error - matlabComplex JOIN using multiple tables - sqlDoes Keras LSTM support dynamic sentence length or not? - deep-learningFirefox does not initialize from jenkins. GDK_BACKEND does not match the available displays. - firefoxpylint не может найти google.cloud - python-2.7Separate all columns in one data frame and create two data frames in R - rAll Articles