There are cases where one uses an always_false
helper to e.g. cause unconditional static_assert
failure if instantiation of some template is attempted:
In C++20, with lambda, you might do something like:
template <class... T> struct always_false : std::false_type {};
// To have true, but for a type that user code can't reuse as lambda types are unique.
template <> struct always_false<decltype([](){})> : std::true_type{};
just use option -fdelayed-template-parsing
To paraphrase Jarod's idea, It could be something like
template <class... T> struct always_false : std::false_type {};
template <> struct always_false</* implementation defined */> : std::true_type{};
Where /* implementation defined */
can be filled by std::_ReservedIdentifer
. User code can't access it, since the identifier is reserved to the library, but there exists a specialization that is true
. That should avoid questions about the ODR and lambdas in specializations.