This seems to be a key point in the article.
Quote:
Originally Posted by Herb Sutter
Printable View
This seems to be a key point in the article.
Quote:
Originally Posted by Herb Sutter
The 3 functions in that article arent nontemplate functions. And again, im discussing order here, which i believe is the source of confusion.
If we had a strict rule about template ordering that all compilers were to obey by then the different results we have gotten here wouldnt have occurred.
From my understanding, GCC follows the rule, (that is also set in Joshutis's book), that templates have to be seen by the *calling template* before they can be called, otherwise, they're not taken into consideration.
From my experience:-
- GCC requires ordered template functions. In that a template has to have been seen by a *calling template* before another can call it. That is -
template Func A;
template Func B;
template Func C;
With regard to GCC, Func B only knows about, and can only call A
- Visual Studio does not require ordered template functions.
template Func A;
template Func B;
template Func C;
With regard to VS, Func B can call A and C.
Again, this is from my experience with codeblocks and VS. I dont know how compliant GCC is, but its what ive come to understand.
In Example 1, function (f) is a non-template function.
Code:// A function template with two overloads
template<class T> void f( T ); // (b)
template<class T> void f( int, T, double ); // (c)
// A separate base template that overloads (b) and (c)
// -- NOT a partial specialization of (b), because
// there's no such thing as a partial specialization
// of a function template!
template<class T> void f( T* ); // (d)
// A full specialization of (b) for int
template<> void f<int>( int ); // (e)
// A plain old function that happens to overload with
// (b), (c), and (d) -- but not (e), which we'll
// discuss in a moment
void f( double ); // (f)
:P
well ok, but i was meaning the main chunk of the article rather than the introductory stuff, under the title
Why Not Specialize: The Dimov/Abrahams Example