c++/7136: Template constants deduction

Philippe A. Bouchard philippeb@videotron.ca
Thu Jan 23 05:36:00 GMT 2003


The following reply was made to PR c++/7136; it has been noted by GNATS.

From: "Philippe A. Bouchard" <philippeb@videotron.ca>
To: bangerth@dealii.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org,
 nobody@gcc.gnu.org, philippeb@videotron.ca, gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/7136: Template constants deduction
Date: Thu, 23 Jan 2003 00:29:38 -0500

 Yes you're right but the following won't work either under gcc 2.95:
 
 struct Type
 {
  int i;
 };
 
 template <typename _T, int _T::* _I>
  struct Number {};
 
 template <typename _T, int _T::* _I>
  void foo(Number<_T, _I> const &)
  {
  }
 
 int main()
 {
  foo(Number<Type, & Type::i>());
 }
 
 Returns:
 template.cpp: In function `int main()':
 template.cpp:15: no matching function for call to `foo
 (Number<Type,&Type::i>)'
 
 
 
 Philippe
 
 
 ----- Original Message -----
 From: <bangerth@dealii.org>
 To: <gcc-bugs@gcc.gnu.org>; <gcc-prs@gcc.gnu.org>; <nobody@gcc.gnu.org>;
 <philippeb@videotron.ca>
 Sent: Wednesday, January 22, 2003 10:16 PM
 Subject: Re: c++/7136: Template constants deduction
 
 
 > Synopsis: Template constants deduction
 >
 > State-Changed-From-To: analyzed->closed
 > State-Changed-By: bangerth
 > State-Changed-When: Thu Jan 23 03:16:59 2003
 > State-Changed-Why:
 >     Nathan must have been having his afternoon nap when he
 >     confirmed this report :-)
 >
 >     The code is actually illegal, and gcc tells you quite
 >     correctly what is wrong:
 >     -----------------------------
 >     struct Type { int i; };
 >
 >     template <typename _T, int _T::*>
 >     struct Number {};
 >
 >     template <typename _T, int _T::*>
 >     void foo(Number<_T, int _T::*> const &)
 >     {}
 >
 >     int main() {
 >       foo(Number<Type, &Type::i>());
 >     }
 >     ------------------------------
 >
 >     In the argument list to foo(), the second template
 >     parameter to Number is "int T::*", which is a type, not
 >     a value. That's what the compiler is complaining about. In
 >     the call to foo(), the second argument is a value, as it
 >     should be.
 >
 >     W.
 >
 >
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p
 r=7136
 >
 



More information about the Gcc-prs mailing list