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]

[Bug c++/29425] New: template template + default parameter = selection failure


Maybe you've got this already but I don't see it. The following fails
to compile (reports an ambiguity) in g++ 4.0.3:

   #include <iostream>

   template<class A, class B=int>
   class two { };

   template<class T>
   struct print {
      void operator()(void) const
         { std::cout << "1" << std::endl; }
   };

   template<template<class> class T, class A>
   struct print< T<A> > {
      void operator()(void) const
         { std::cout << "2" << std::endl; }
   };

   template<template<class, class> class T, class A, class B>
   struct print< T<A,B> > {
      void operator()(void) const
         { std::cout << "3" << std::endl; }
   };

   int main(void)
   {
      print< two<int,int> >()();
   }

Two other compilers I've tried, Portland Group and Intel, compile
the code; the executables print "3". That's what I'd have expected.

If class B isn't defaulted in class template "two," there's no
problem.

Martin


-- 
           Summary: template template + default parameter = selection
                    failure
           Product: gcc
           Version: 4.0.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mstaley at lanl dot gov


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29425


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