1

cppreference says that, until C++14, a constexpr function must satisfy the following requirement:

the function body must be either deleted or defaulted or contain only the following:

  • null statements (plain semicolons)
  • static_assert declarations
  • typedef declarations and alias declarations that do not define classes or enumerations
  • using declarations
  • using directives
  • if the function is not a constructor, exactly one return statement

Yet the example contains many other elements.

Is the requirement misstated or am I misunderstanding something?

4
  • 3
    Which of these do you think is violated in the examples? Commented Nov 26, 2024 at 15:50
  • 3
    Note example have this: #if __cplusplus >= 201402L to exclude code of factorial_cxx14. Commented Nov 26, 2024 at 15:52
  • 2
    "Until C++14" means these are requirements only before C++14, that is C++11. The C++11 example has only one return statement. Commented Nov 26, 2024 at 18:54
  • @LHLaurini, do you mean that the "until" is exclusive? I was under the impression it was inclusive. Hmmm... You're right, English thing. Feel free to submit an answer. Commented Nov 26, 2024 at 21:47

1 Answer 1

2

On cppreference.com, you'll often find pages, identifiers, declarations, definitions and blocks of text annotated with one of:

  1. (C++XX)
  2. (since C++XX)
  3. (until C++XX)
  4. (since C++XX)
    (until C++YY)

where XX and YY indicate standard revisions (currently one of 98, 03, 11, 14, 17, 20, 23 or 26).

The first and second are equivalent and mean that the annotated element is applicable for C++XX and later.

The third type of annotation, on the other hand, indicates that the annotated element was applicable before C++XX. Starting from C++XX, such element is not applicable anymore.

Finally, the fourth type of annotation (less common), indicates that the annotated element is applicable for C++XX and later, up to, but not including, C++YY.


All of these annotations can make some pages harder to read. If you only care about a certain revision, you can select it on the "Standard revision" drop-down menu located in the top-right corner. Doing so will hide everything that's not relevant for the chosen revision.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.