One of those who is “right compiler” asks questions about templates. Consider the following:
template<typename T> class Container { public: template<typename V> class iterator; }; template<typename T> template<typename V> class Container<T>::iterator { public: iterator &operator++(); };
Now, when you provide a definition for operator++ out-of-line, it will look like this:
template<typename T> template<typename V> typename Container<T>::template iterator<V> &Container<T>::iterator<V>::operator++() { //do your thing return *this; }
And for sure, almost any version of GCC from 4.8+ and Clang 3.2+ can compile it. MSVC19 +, however, does not do this, and he especially dislikes the template keyword in this definition. He complains that he cannot compare with the announcement and the definition, which is especially funny as he gives what he is looking for and the “candidate”, and they are both identical. If template is deleted, therefore only typename Container<T>::iterator<V> , MSVC simply compiles it. However, Clang and GCC will fail.
You can try it live on Compiler Explorer: live demo
So who is right? Because GCC and Clang have this for a long time, I am inclined to them. However, I would like to support all three. Therefore, either I turn to the definition of the class, or use #ifdef ? It seems wrong, and if the MSVC is wrong here, it should be reported (if this is not a known issue).
c ++ visual-c ++ templates
Resurrection
source share