THis is where I put wierd ideas I have. Sort of like a scratch-pad.
The functor trick was iunspired by Scott Meyers at the C++ Seminar. Basically, he wanted a way to get around this problem: Consider the code:
void foo(vector<int> v, list<int> w) { transform( v.begin(), v.end(), w.begin(), v.begin(),multipliesNote the redundancy. So Scott came up with a functor); }
NewMultiplies
which behaves like
multiplies<T>
except for the special case of
multiplies<void>
, which creates member templates.
So I
thought, "why not make multiplies a template parameter, so we can do
the same with plus, divides, etc and just plug in the functor to the
template ?" And I ended up with my stupid functor trick.
The mixed argument deduction code is quite difficult to read. Basically, the promote template, the get_template_parameter, and get_result_type templates are all there to handle mixed arguments (and annoy the reader)
Just a bizarre idea I had. Why not play around with templates to make multi-dimensional arrays ? Template abuse is fun, and this is a situation where it's useful, at least for people who actually like multidimensional arrays.