This is the mail archive of the 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]

Template Template Matching Problem on Defaults (old g++ extension induced problem -- bug 9737)

Hash: SHA1

At some point in time an extension was added to g++ in order to make a 
template template specialization for n parameters match a template with n+m 
parameters, when the extra m parameters have default values.  This cause the 
undesirable side effect of breaking the breaking the following (valid) code 
(I verified this with g++ 3.3-3.5):

- ---
template<typename> struct match { };
template<template<typename> class t_,typename T_> 
struct match<t_<T_> > { typedef int type; };
template<template<typename,typename> class t_,typename T0_,typename T1_>
struct match<t_<T0_,T1_> > { typedef int type; };

template<typename,typename _=void> struct other { };

typedef match<other<void,void> >::type type;

Bug.cpp:9: error: ambiguous class template instantiation for `struct 
match<other<void, void> >'
Bug.cpp:5: error: candidates are: struct match<t_<T0_, T1_> >
Bug.cpp:3: error:                 struct match<t_<T_> >
- ---

A patch to make the compiler compliant with regards to this issue was provided 
in April 2003.  The bug was suspended, with out the patching be 
applied/extension being removed, due to possible changes in the next C++ 

Anyone have an update for September 2004?  Is it not part of the standard 
(finger's crossed)?  Can we remove/depreciate this extension (as seemed to be 
the conclusion reached on the mailing list discussion around the submitted 
patch -- so I can 
compile my code (or at least make the g++ specific matching extension bind 
less tightly than what C++ standard choice).

- -T

PS:  I also don't get what analogue this extension was suppose to maintain 
with function function parameters (see bug report).  I just finished 
checking, and g++ certainly does not allow things like assigning an n (non 
default) plus m (default) argument function to an n argument function 

- -- 
 Tyson Whitehead  ( -- WSC-)
 Computer Engineer                          Dept. of Applied Mathematics,
 Graduate Student- Applied Mathematics      University of Western Ontario,
 GnuPG Key ID# 0x8A2AB5D8                   London, Ontario, Canada
Version: GnuPG v1.2.5 (GNU/Linux)


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