![]() |
STD-DISCUSSION |
Subject: Re: Can static_assert(false) be ignored in if constexpr?
From: Richard Hodges (hodges.r_at_[hidden])
Date: 2021-01-13 10:15:43
>
>
>
> I wish there was an established solution for this.
>
Another hack. Pick your poison:
template<class T>
constexpr bool compile_time_logic_error(T&&)
{
throw "compile time logic error";
}
template <typename T>
ReturnType Function(T&& arg)
{
if constexpr(condition_on_<T>) {
// Something to do
} else if constexpr(another_condition_on<T>) {
// Something else to do
} else {
constexpr auto _ = compile_time_logic_error(arg);
}
// Some common processing regarding arg
return 0;
}
STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org