Re: "Function template" problem
From: Lionel B (google_at_lionelb.com)
Date: 09/30/04
- Next message: CBFalconer: "Re: #include optimization"
- Previous message: Jef Driesen: "Re: Implementing a templated "round" function?"
- In reply to: Gernot Frisch: "Re: "Function template" problem"
- Next in thread: Markus Moll: "Re: "Function template" problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Sep 2004 03:35:44 -0700
Gernot Frisch wrote:
> <google@lionelb.com> schrieb im Newsbeitrag
> news:1096533787.039138.214520@k26g2000oda.googlegroups.com...
> > Gernot Frisch wrote:
> >> "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);
> >
> > Apologies if I'm being obtuse, but I don't understand this reply at
> > all
> > :(
>
> er... do you know what templates are and what you use them for?
Yes.
> What are you trying to do? I don't get a clue from your source code,
> that I have in common with your compiler ;)
I am implementing Todd Veldhuizen's "Pointer-to-function as a template
parameter" scheme to inline callbacks in extensive loops. See
http://osl.iu.edu/~tveldhui/papers/techniques/ (Section 1.4) for the
rationale behind the technique.
My sample code is a "minimalist example" of the real problem which
arose when trying to build a template class (my class B above) with a
function (my function B::foo) that calls the member template function
(my A::eval) for a member object (my B::a). I hope this is clear(ish).
The (rather esoteric) solution I was looking for was supplied by Markus
Moll in a previous post.
Regards,
-- Lionel B
- Next message: CBFalconer: "Re: #include optimization"
- Previous message: Jef Driesen: "Re: Implementing a templated "round" function?"
- In reply to: Gernot Frisch: "Re: "Function template" problem"
- Next in thread: Markus Moll: "Re: "Function template" problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|