On Tuesday, 9 June 2015 at 07:58:04 UTC, Kagamin wrote:
On Monday, 8 June 2015 at 22:22:51 UTC, Andrei Alexandrescu
wrote:
On 6/8/15 1:25 PM, ponce wrote:
C++'s constexpr looks broken because everything must be marked
constexpre, which defeats the purpose of having compile-time
code
looking like runtime code. But I never had the pleasure to
use it.
Yeah, it's sadly quite björked. Scott Meyers and I looked at
the feature and the logical conclusion for a guideline was
"Speculatively mark everything in sight as constexpr". That
doesn't quite scale. -- Andrei
Same as with @safe @nogc @nothrow @pure. If you don't have
ctfeability expressed in function's contract, you have no idea
how you can modify the function's implementation so that to not
break other people's code. Sorry for making c++ look cute again
:)
static assert() is your friend in this case. See also the related
problem of guaranteeing that a template is nothrow/@nogc/whatever
by itself (i.e. doesn't do anything that violates them), even
though it cannot be marked as such because that would preclude
instantiating it with certain types that aren't nothrow/@nogc.