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]

Re: c++/7136: Template constants deduction


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
>


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