sparrow 1.0.0
Loading...
Searching...
No Matches
sparrow::mpl::dependent_false< T > Struct Template Reference

Workaround to replace static_assert(false) in template code. More...

#include <mp_utils.hpp>

Inheritance diagram for sparrow::mpl::dependent_false< T >:
[legend]
Collaboration diagram for sparrow::mpl::dependent_false< T >:
[legend]

Detailed Description

template<class... T>
struct sparrow::mpl::dependent_false< T >

Workaround to replace static_assert(false) in template code.

This utility provides a way to trigger compilation errors in template contexts where static_assert(false) would cause immediate compilation failure even in non-instantiated branches.

Reference: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2593r1.html

Template Parameters
TPack of types (unused but makes the false condition dependent)
Postcondition
Always inherits from std::false_type
template<typename T>
void func() {
if constexpr (some_condition<T>) {
// do something
} else {
static_assert(dependent_false<T>::value, "Unsupported type");
}
}
Workaround to replace static_assert(false) in template code.
Definition mp_utils.hpp:54

Definition at line 53 of file mp_utils.hpp.


The documentation for this struct was generated from the following file: