Today I came to know that C++ allows non-type template parameters of type std::nullptr_t:
template<std::nullptr_t N> struct A { };
template<std::nullptr_t N> void f() { }
For the life of me, I cannot come up with any sensible use-case for these. Can anyone please come up with a rationale for this?
It seems this is allowed to avoid the need to special case template using a pointer type and a value for
std::nullptr_t. That, the use case would look look something like this:That is, pointer values can be template arguments and, thus,
nullptrshould be, too.