4 ms·
But we already do. > So you can eliminate temporaries at compile time. > ... but the library user can just write A + B + C ... > So Rust has that. Eliminati
by menaerus 3y ago
But we already do.
> So you can eliminate temporaries at compile time.
> ... but the library user can just write A + B + C ...
> So Rust has that.
Eliminating temporaries in C++ is also done in compile-time through expression templates or more generally through TMP.
I'm pretty sure Rust type system is incapable to express many (?) of the TMP things from C++ - it does not even support partial specializations to begin with so it's hard to imagine that you can do a lot of TMP gymnastics. I think that this is an area where it is generally accepted that Rust is lacking against C++.
- panzi 3y agoYeah, I was listing a lot of things that C++ can express that Rust can't. But C++ doesn't have lifetimes so you can't express those. And you can use that to eliminate temporaries. But if you say that you can also somehow do that with template meta programming then great!