3 ms·
"constexpr Box getBox() const noexcept override" - this signature is just ridiculous. Can't compiler at least infer "const noexcept" from "constexpr"? In the m
by dshpala 5y ago
"constexpr Box getBox() const noexcept override" - this signature is just ridiculous. Can't compiler at least infer "const noexcept" from "constexpr"?
In the meanwhile, how is C++ lifetime profile doing, is it useable yet?
I know C++ pretty well, but I'd pick Rust (or Zig) for my next project.
- gumby 5y agoThe const and constexpr keywords mean different things. Declaring a method const tells the compiler that that method won’t change the object. Declaring something constexpr tells the compiler that if its arguments are known at compile time then it will always return the same result and may be a candidate for “invocation” at compile time. The fact that the keywords both contain the string “const” is a consequence of the English language.
- nybble41 5y agoUntil C++14 constexpr on a non-static member function did actually imply const, since mutation was (logically enough) not permitted in constexpr functions. C++14 relaxed this restriction, however, by allowing constexpr functions to mutate objects which only exist within the lifetime of the constexpr expression, so constexpr no longer implies const.
- aldanor 5y agoThe signature reminds me of dlang somewhy, with its "pure nothrow @safe @nogc" etc.
- pjmlp 5y agoLifetime static analysis is still pretty much experimental in clang and VC++. As for inference, maybe in the example, although in most code bases with binary libraries it would be useless anyway.