4 ms·
Should we think of them like the equivalent of constexpr functions in C++?
by lultimouomo 8y ago
Should we think of them like the equivalent of constexpr functions in C++?
- steveklabnik 8y agoI am not familiar enough to declare an equivalence, but roughly the same, yes.
- tux3 8y agoYes, but hopefully without the amusing issue of non-constant constexpr functions in C++ :) http://b.atch.se/posts/non-constant-constant-expressions/ http://b.atch.se/posts/non-constant-constant-expressions/
- PowerGuido87 8y agoSo they're more like C++20's consteval? http://wg21.link/p1073r3 http://wg21.link/p1073r3
- tux3 8y agoAs I understand it, not really no. The conceptual difference between constexpr and consteval is that consteval is guaranteed to be evaluated at compile-time, so unlike constexpr code, consteval code will never actually end up as a function in your binary. Rust's const fns on the other hand can be called at runtime, so in that respect they'd be closer to constexpr.