Question 11
Back to Exercise
Why use if constexpr rather than if inside a template?
- A It is faster at run time
- B The untaken branch is discarded at compile time, so it may contain code that would not compile for that type Correct
- C It allows run-time types
- D It works outside templates only
Correct Answer: Option B
With a normal if, both branches must compile for every T.
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!