Is there a workaround to do something like this?
if constexpr (std::floating_point<T>) {}
else if constexpr (std::integral<T>) {}
...
else static_failure("Feature expansion needed");
because if I replace static_failure with static_assert, it needs the replication of all the above conditions (they are many and complicated) and it becomes ugly.
// It does not work properly: always fail
else static_assert(false, "Feature expansion needed");
// works fine, but it is ugly
else static_assert(std::floating_point<T> || std::integral<T> || ... || ... || ..., "Feature expansion needed");
I do not prefer a runtime behavior like:
throw "Feature expansion needed";
>Solution :
Yes, you just need the static assert to be dependant on T and always be false like this:
if constexpr (std::is_integral_v<T>) {}
else
static_assert(sizeof(T) < 0, "Only works for integral T");
https://godbolt.org/z/Yhesd58rK