On Thu, 19 Jul 2007 21:19:09 -0300, Rodolfo Lima wrote > In my first example, the target type is the type of the address > expression, It cannot be treated as the target in paragraph 1 of section 13.4 (ISO/IEC 14882:2003). Again, here is the list of possible targets: 1. an object or reference being initialized (8.5, 8.5.3), 2. the left side of an assignment (5.17), 3. a parameter of a function (5.2.2), 4. a parameter of a user-defined operator (13.5), 5. the return value of a function, operator function, or conversion (6.6.3), 6. an explicit type conversion (5.2.3, 5.2.9, 5.4), or 7. a non-type template-parameter (14.3.2).
Obviously, {1, 2, 4, 5, 6, 7} are not matched. Maybe you think that the item 3 is matched. Unfortunately, it stands for the non-template functions. BTW, here are two important sentences after the 7 items: "The overloaded function name can be preceded by the & operator. An overloaded function name shall not be used without arguments in contexts other than those listed." Here is you original example code: ========== #include <iostream> using namespace std; void print() { cout << "null" << endl; } template<int i> void print() { cout << i << endl; } template<int i, int j> void print() { cout << i << ' ' << j << endl; } template <class F> void call(F f) { f(); } int main() { // proper way (according to g++) to call non-templated print // call(static_cast<void(*)()>(&print)); call(&print); call(&print<5>); call(&print<7,6>); return 0; } ========== If you want to match the item 3, you have to replace the definition of call<> () to a non-template function: ========== void call(void (*f)()) { f(); } ========== And then it can be passed by g++. The 2nd line of main() which you marked is matched by item 6. Hence it can also compiled by g++. Again, the set of overloaded function has never contain anything in your original example. It's because you don't have any targets which are matched to any items of list in paragraph 1 of section 13.4. Maybe you think that it contained the non-template one at begining. No, it's also not in the set.