Comment by aw1621107
34 minutes ago
I had always thought expression templates at the very least needed the optimizer to inline/flatten the tree of function calls that are built up. For instance, for something like x + y * z I'd expect an expression template type like sum<vector, product<vector, vector>> where sum would effectively have:
vector l;
product& r;
auto operator[](size_t i) {
return l[i] + r[i];
}
And then product<vector, vector> would effectively have:
vector l;
vector r;
auto operator[](size_t i) {
return l[i] * r[i];
}
That would require the optimizer to inline the latter into the former to end up with a single expression, though. Is there a different way to express this that doesn't rely on the optimizer for inlining?
No comments yet
Contribute on Hacker News ↗