Re: "Function template" problem
From: Gernot Frisch (Me_at_Privacy.net)
Date: 09/30/04
- Next message: Jef Driesen: "Implementing a templated "round" function?"
- Previous message: Lionel B: ""Function template" problem"
- In reply to: Lionel B: ""Function template" problem"
- Next in thread: google_at_lionelb.com: "Re: "Function template" problem"
- Reply: google_at_lionelb.com: "Re: "Function template" problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 30 Sep 2004 10:02:08 +0200
"Lionel B" <google@lionelb.com> schrieb im Newsbeitrag
news:e1308e8b.0409292355.34df10ed@posting.google.com...
> Greetings,
>
> I cannot figure out why the following code does not compile:
>
> --- BEGIN CODE ---
>
> typedef double ftype(double);
what you do is:
template <double f> double func(f x);
But: You don't want to give the type of the template argument, since
it's a "template".
So, use
template<class C> double fkt(C argC);
>
> struct A
> {
> double x;
>
> template<ftype F>
> double eval()
> {
> return F(x);
> }
> };
>
> template<ftype F>
> struct B
> {
> A a;
>
> double foo()
> {
> return a.eval<F>();
> }
> };
>
> --- END CODE ---
>
> It generates the error message:
> scratch.cpp: In member function `double B<F>::foo()':
> scratch.cpp:23: error: parse error before `;' token
>
> [ line 23 being return a.eval<F>(); ]
>
> Compiler gcc (GCC) 3.3.3 (cygwin special) on Win2K
>
> Any help appreciated,
>
> --
> Lionel B
- Next message: Jef Driesen: "Implementing a templated "round" function?"
- Previous message: Lionel B: ""Function template" problem"
- In reply to: Lionel B: ""Function template" problem"
- Next in thread: google_at_lionelb.com: "Re: "Function template" problem"
- Reply: google_at_lionelb.com: "Re: "Function template" problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|