79454964

Date: 2025-02-20 15:18:21
Score: 0.5
Natty:
Report link

As to explain why your code is wrong
constexpr is meant to eliminate all side effects and to have the calculation doable at compilation time (even though it can also be called during runtime).
As soon as you dereference the non-constexpr this pointer you depend on a runtime instance, no matter what the method will do.

As @Jarod42 pointed out in the comments:
When you make isTrue as a static constexpr method, then you don't need the this pointer and the expression has no more side effects.
Use

if constexpr (isTrue<int>())

or more explicitly

if constexpr (struct serialiser_deserialiser::isTrue<int>())
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Jarod42
  • Low reputation (0.5):
Posted by: Thibe