tags:

views:

137

answers:

3

A function template can be overloaded with other function templates and with normal (non-template) functions. A normal function is not related to a function template(i.e., it is never considered to be a specialization), even if it has the same name and the type as a potentially generated function template specialization.

This is the statement from ISO C++ Standard Section 14.5.5, 2nd point. Can this statement be proven wrong?

Edited: I need to disprove it, and for that i need to create a code snippet that will test whether or not this statement holds true.

Can anyone provide a code snippet?

+1  A: 

I really don't think you should be arguing with the C++ standard. If you must disprove it, create a code snippet that will test whether or not this statement holds true.

Alexander Rafferty
yeah iam trying for that ..code snippet...actually..i created the snippet to prove this statement...yeah ..it is proved..but i need to check..it..in negative form also...that means if we violate this rule..it should..show error....
BE Student
Are you challenging the C++ standard (don't bother) or just your compiler (do bother)?
Alexander Rafferty
Iam checking the compilers...whether they are following..the satndard,...or not.it is our project..work..that is on templates
BE Student
well, I suppose that would be okay. Sometimes compilers could have very minor bugs. But any big compilers, e.g. the visual compiler, would likely be scrutinized for months before each release.
Alexander Rafferty
+2  A: 

This is the standard. How can you prove it wrong? There is nothing wrong or right here. It is as it is. If you find this is not as it is stated, then the compiler/platform is not following the standard.

Manoj R
+5  A: 

This is purely based on what I understand from your defintion of 'negative' and 'fail'. These example show how to make overload resolution fail in some of the common situations

// Case 1: Two non template functions participating in overload resolution (and failing)

namespace A1{
    void f(){}
}

namespace A2{
    void f(){}
}

using A1::f;
using A2::f;

int main(){
   f();
}

Here the compilers will give error related to the fact that the call to 'f' is ambiguous as there are two viable functions. This proves that overload resolution is happening (and failing).

Case 2: // A template and a non template participating in an unsuccessful overload resolution

namespace A1{
    template<class T> int f(){}
}

namespace A2{
    void f(int){}
}

using A1::f;
using A2::f;

int main(){
   f();
}

// Case 3: Two template functions participating in a failed overload resolution

namespace A1{
        template<class T> int f(T, int){return 0;}
}

namespace A2{
        template<class T> double f(T, int){return 0;}
}

using A1::f;
using A2::f;

int main(){
   f(2.2, 2.2);
}

OR better still

namespace A1{ 
        template<class T> int f(T, int){return 0;} 
} 

namespace A2{ 
        template<class T> double f(int, T){return 0;} 
} 

using A1::f; 
using A2::f; 

int main(){ 
   f(2.2, 2.2); 
} 
Chubsdad
Thank You very much Chubsdad...
BE Student