This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/7136: Template constants deduction
- From: "Philippe A. Bouchard" <philippeb at videotron dot ca>
- To: bangerth at dealii dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org,nobody at gcc dot gnu dot org, philippeb at videotron dot ca, gcc-gnats at gcc dot gnu dot org
- Date: Thu, 23 Jan 2003 00:29:38 -0500
- Subject: Re: c++/7136: Template constants deduction
- Organization: Fornux SNC
- References: <20030123031659.5681.qmail@sources.redhat.com>
- Reply-to: "Philippe A. Bouchard" <philippeb at videotron dot ca>
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
>