LearnFrenzy
Sign in Take a free test

Functions and Default Arguments · Functions MCQ · Question 13

When is a constexpr function evaluated? Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 13 Back to Exercise

When is a constexpr function evaluated?

  • A Always at compile time
  • B At compile time when used in a constant expression with constant arguments; otherwise it can run at run time Correct
  • C Always at run time
  • D Only inside templates
Correct Answer: Option B

That flexibility is the difference from consteval (C++20), which must always be evaluated by the compiler.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links