Bug 29425 - template template + default parameter = selection failure
Summary: template template + default parameter = selection failure
Status: RESOLVED DUPLICATE of bug 9737
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-10 23:57 UTC by mstaley
Modified: 2006-10-11 00:43 UTC (History)
13 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mstaley 2006-10-10 23:57:11 UTC
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
Comment 1 Andrew Pinski 2006-10-11 00:43:01 UTC
Fixed for 4.2.0.  This is also a dup of bug 9737.

*** This bug has been marked as a duplicate of 9737 ***