This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gcc 3.3.3 bug(?): "ambiguous class template instantiation"


Hallo,

The following code does not compile with gcc 3.3.3 
but compiles fine with comeau.
Has anybody a fix or can help?

David

-------------------
#include <list>
#include <string>

template< typename TTarget, class TSource >
struct test;


template< typename TTarget, typename TCh, class TTr, class TAl >
struct test< TTarget, std::basic_string<TCh,TTr,TAl> > {
    static TTarget f()
        {
            return TTarget();
        }
};

template< typename TTarget, class TString, class TAl, template<class,class> 
class TCont >
struct test< TTarget, TCont<TString,TAl> > {
    static TTarget f()
        {
            return TTarget();
        }
};

template< typename TTarget, class TSource >
TTarget do_test(const TSource&)
{
    return test<TTarget,TSource>::f();
}

int main()
{
    std::string s;
    std::list<std::string> l;
    int i1 = do_test<int>(s);
    int i2 = do_test<int>(l);
    return i1+i2;
}
---------------------------

The gcc error is: 


test.cpp: In function `TTarget do_test(const TSource&) [with TTarget = int,
   TSource = std::string]':
test.cpp:34:   instantiated from here
test.cpp:27: error: ambiguous class template instantiation for `struct
   test<int, std::string>'
test.cpp:17: error: candidates are: struct test<TTarget, TCont<TString, TAl> 
>
test.cpp:9: error:                 struct test<TTarget, 
std::basic_string<TCh,
   TTr, TAl> >
test.cpp:27: error: incomplete type 'test<int, std::string>' cannot be used 
to
   name a scope



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]