For my matrix class I want to do some sort of operator overloading (probably using expression templates) on range-v3 views for + - / * %
.
For example if I want to get a view of the sum of two columns, I want to write
col_1 + col_2
instead of
rv::zip_with([](auto c1, auto c2) {return c1 + c2;}, col_1, col_2);
Probably some ideas from this paper can be used to avoid constructing too many temporaries. Here is the code that I want to write:
//simple example
//what I want to write
auto rangeview = col_1 + col_2;
//what I can write
auto rangeview = rv::zip_with([](auto c1, auto c2) {
return c1 + c2;
}, col_1, col_2);
//itermediate
//what I want to write
auto rangeview = col_1 + col_2 + col_3;
//what I can write
auto rangeview = rv::zip_with([](auto c1, auto c2, auto c3) {
return c1 + c2 + c3;
}, col_1, col_2, col_3);
//advanced
//what I want to write
auto rangeview = 10*col_1 + 20*col_2 - 30*col_3;
//what I can write
auto rangeview = rv::zip_with([](auto c1, auto c2, auto c3) {
return 10.0*c1 + 20.0*c2 - 30.0*c3;
}, col_1, col_2, col_3);
//more advanced with elementwise multiplication
//what I want to write
auto rangeview = 10*col_1 + 20*col_2 - col_2 % col_3;
//what I can write
auto rangeview = rv::zip_with([](auto c1, auto c2, auto c3) {
return 10.0*c1 + 20.0*c2 - c2*c3;
}, col_1, col_2, col_3);
std::plus<>
(orranges::plus
). – Ultrastructure