From: Vinícius d. S. O. <vin...@gm...> - 2014-06-15 23:27:05
|
2014-06-15 20:12 GMT-03:00 Johan Engelen <jbc...@sw...>: > Thanks for that idea. Do you know if there is a good reason for that > design? Perhaps default template arguments are a bad idea / hinder future > development? > The two are very alike. The difference is when you type more. With the typedef solution, you'll have to type more (the "basic_" prefix) when you want to write a generic function. With the default type argument solution, you'll have to type more when you want to write the common case and non-generic version (the "<>" suffix). https://gist.github.com/vinipsmaker/c277a3268c8a79ce8584 The idea was to allow you to refactor incrementally and still being able to compile the code base. I haven't thought about the other implications. I am a bit worried that it will hide functions that should be generalized > to work with all kinds of Points, instead of just base_point<double>. > Methods that are defined using Point will be template-specialized > functions, and will not be available for base_point<float>; but I won't > learn about them until some user complains that a certain obscure function > is not available. > Unfortunately, Inkscape is the only real (somewhat extensive) testcase > that we have... > I guess this is solved by a search for "Point" over the whole codebase, > and changing it where necessary... > Yes, it'd "hide" functions that should be generalized, because they'd continue to work. If you want to search these functions, you could also remove the typedef and see the compiler errors. Then reintroduce the typedef and refactor one more function and so on. -- Vinícius dos Santos Oliveira https://about.me/vinipsmaker |