From: Johan E. <jbc...@sw...> - 2014-06-15 22:02:03
|
Hi all, I am reading Modern C++ Design by Andrei Alexandrescu and already after the first few pages, I want to start work on 2geom that I've been thinking about for a while. Would like to hear your thoughts, encouragement or otherwise :-) The idea is to add template parameters to, e.g., Point. Right now, we hardcode the coordinate type Coord as double. But why not: template<typename Coord = double> class Point { ... }; :) ? This will allow people to choose what precision they want. Perhaps this allows code sharing between Point and IntPoint. Note that with templated stuff, you can write methods that would not work with certain types without breaking compilation (unless you call such a method); this would allow exposing optional functionality depending on the template argument type. Point<double> is just the start. My endgoal is to be able to choose Path<CubicBezier>: a path for which all functions know that it is just a vector with CubicBeziers, allowing SIMD optimization of many operations on it. Instead of the Path<Curve> that we have now, that does not allow for any of that. I am not sure this will improve performance, but I think it will be an interesting and challenging exercise to make lib2geom more general, and go beyond what it already can do. regards, Johan |