On 10/30/15 10:53 AM, John Maddock wrote:
I suspect the explosion of template instances for any non-trivial uses would also explode compile times?
I confess that I never worry about this. I see this concern raised all the time but I never notice it in my own work. One thing I do to is avoid the "convenience" headers and include only the headers I actually know I need so maybe that helps. Also for the serialization library I use make a library component - maybe that speeds up the build of all the applications. also CMake and B2 only recompile changed stuff, so that seems to help also. Anyway - for me this doesn't ever seem a real problem - especially these days.
Of course C++17 may (or not) fix both of the above.
A simpler alternative might be:
template
class polynomial; Which implements a polynomial of maximum order N. Multiplication would have to be mod x^N as I can't think of an error handling mechanism that works for both runtime and constexpr contexts?
Well, I'm not seeing any of this. If I multiply a polynomial of order N and one of order M, I'm going to get a resultant polynomial of order M + N, am I not? Similarly with division I'll get one of M - N (ignoring the admittedly sticky question of the remainder. And what kind of error could mulitplication of polynomials give? I must say I'm quite intrigued with this for C++ 14. I can't justify spending any time on it though. Robert Ramey