I want to use a set of libraries written in C ++ with Intel compilers. I gave an example of code that demonstrates the problem. There are many places in libraries where they use a combination of "use" with partial overload (for example, I want to use the foo (void) method from the base class, but override the second version of fo foo in the derived class) gcc has no problem, but Intel does .
#include <iostream> template <class F> struct Interface { static const F f=10; }; template <class F> struct Base : public Interface<F> { void foo (void) { std::cout << "void" << std::endl; } template <class FF> void foo (Interface<FF> &ii) { std::cout << "F : " << ii.f << std::endl; } }; template <class F,int i> struct Derived : public Base<F> { // void foo (void) { Base<F>::foo(); } // works fine using Base<F>::foo; // gives error template <class FF> void foo (Interface<FF> &ii) { std::cout << "Derived<" << i << "> F : " << ii.f << std::endl; } }; int main (void) { Derived<double,10> o; o.foo(); // ok o.foo (o); // problem }
Compiler error given by icc:
test.cc(30): error: more than one instance of overloaded function "Derived<F, i>::foo [with F=double, i=10]" matches the argument list: function template "void Base<F>::foo(Interface<FF> &) [with F=double]" function template "void Derived<F, i>::foo(Interface<FF> &) [with F=double, i=10]" argument types are: (Derived<double, 10>) object type is: Derived<double, 10> o.foo (o);
If you delete the line
using Base<F>::foo;
and replace it with a string
void foo (void) { Base<F>::foo(); }
everything is working fine.
My question is: does anyone know if this is a special gcc function or icc error? Or is there another work around which will not be related to code changes?
This is with g ++. real (Ubuntu 4.4.3-4ubuntu5) 4.4.3 and icc (ICC) 12.0.2 20110112.
tr1987
source share