On Monday, 8 June 2015 at 19:57:34 UTC, Dmitry Olshansky wrote:
And they seem to almost have CTFE(!)

From wiki on C++14:

C++11 introduced the concept of a constexpr-declared function; a function which could be executed at compile time. Their return values could be consumed by operations that require constant expressions, such as an integer template argument. However, C++11 constexpr functions could only contain a single expression that is returned (as well as static_asserts and a small number of other declarations).

C++14 relaxes these restrictions. Constexpr-declared functions may now contain the following:[5]

    Any declarations except:
        static or thread_local variables.
        Variable declarations without initializers.
    The conditional branching statements if and switch.
    All looping statements, including range-based for.
Expressions which change the value of an object if the lifetime of that object began within the constant expression function. This includes calls to any non-const constexpr-declared non-static member functions.

goto statements are forbidden in C++14 relaxed constexpr-declared functions.

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.

Reply via email to