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>())