specfem::utilities::always_false¶
-
template<auto... T>
constexpr bool specfem::utilities::always_false = false¶ Always-false template variable helper for static assertions.
Used in if-constexpr branches and static_assert statements to generate compile-time errors only when a specific template instantiation occurs. This is more robust than using false directly, which could trigger warnings or be optimized incorrectly.
template<typename T> void process() { if constexpr (std::is_same_v<T, int>) { // handle int } else { static_assert(always_false<T>, "Unsupported type"); } }
- Template Parameters:
T – Template parameter pack (values are ignored)