What is a proper use-case of `std::nullptr_t` template parameters?
c++, templates
Solution
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:
template <typename T, T Ptr>
struct pointer_object {
static T get_pointer() { return Ptr; }
};
int int_ptr(0);
typedef pointer_object<int*, &int_ptr> int_ptr_t;
typedef pointer_object<std::nullptr_t, nullptr> null_ptr_t;
That is, pointer values can be template arguments and, thus, `nullptr` should be, too.
Problem
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?