[gameprogrammer] Re: c++ template problem
- From: Madison McGaffin <greyhill@xxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Wed, 22 Jul 2009 07:53:14 -0400
Something I've seen done which hasn't been mentioned yet is partial
template specialization
( http://www.cprogramming.com/tutorial/template_specialization.html ) on
the dimension (N) of Vector<N, T>. It's a good bit of typing initially
(because you won't be using inheritance) but you get a nice, single
interface for all your vector classes; Vector<2, T> and Vector<3, T>'s
can be optimized to your heart's content; and you can add
dimension-specific things like the cross product to Vector<3, T>. And,
if you need it, you can still create 25-dimensional vectors for whatever
else you might want.
On Sun, 2009-07-19 at 16:18 +0200, Felde Norbert wrote:
> Thanks.
> The problem was that the va_list dous not handle float type.
> I need to get the parameter as double and than convert it to float which
> makes it difficult to implement it as template.
>
> I could not find out yet the problem of the derived vect3 class.
>
> fenor
>
>
>
>
> Matthew Weigel írta:
> > Felde Norbert wrote:
> >
> >
> >
> >> The c'tor should get the values of the coordinates, but because of the
> >> template parameter N, I do not know
> >> how many parameter the c'tor should get. I tried that:
> >>
> >> Vect<T,N>(T v0, T v1, ...) {
> >> va_list params;
> >>
> >> V[0] = v0;
> >> V[1] = v1;
> >>
> >
> > Other people report having success with this kind of code online, e.g.
> > http://groups.google.com/group/microsoft.public.vc.language/browse_thread/thread/25e1820b7f894bde
> >
> > As a starting point, why don't you try building and running the code
> > from that link (without the reference in the constructor) and see if you
> > have any problems.
> >
>
>
> ---------------------
> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
>
>
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
Other related posts: