|
|
In article <397d8cb8@news.povray.org> , Warp <war### [at] tagpovrayorg> wrote:
> What is shorter, to write the 6 lines of code above for every pair of
> structs you use, or just write the swap function directly?
>
> Perhaps in this case it could be better to have a 'swap' method inside
> the classes/structs, so you could write:
>
> a.swap(b);
For the swap function this is to long, yes, but what about classes similar
to ones link vector<>, list<> or map<> templates in C++? While in many
cases good old void pointers will do, it is possible to use macros instead.
Anyway, my point was not that templates are easy and good to do in C, just
that it is possible with a little bit of work to get a lot of features of
C++ in C - and the three lines would be exactly what it would takes to
implement a vector<> template of any class in C.
Thorsten
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde
Visit POV-Ray on the web: http://mac.povray.org
Post a reply to this message
|
|