As seen on http://en.cppreference.com/w/cpp/memory/pointer_traits and related sites (also the boost implementation by boost intrusive), pointer_traits is not specialized for T*const. Why is that?
Although this does not qualify as a strong motivation against specifying that a specialization of pointer_traits<> for T* const should exist, I guess an explanation why it was not included could be that pointer_traits<> is mostly meant to be used in a context where template argument deduction (and in particular type deduction) occurs.
Since type deduction disregards top-level cv-qualifications, a specialization for T* const or T* volatile or T* const volatile was probably deemed unnecessary:
#include <type_traits>
template<typename T>
void foo(T)
{
static_assert(std::is_same<T, int*>::value, "Error"); // Does not fire!
// ^^^^
}
int main()
{
int x = 0;
int* const p = &x;
foo(p);
}
Of course this does not mean that having a specialization for T* cv would harm in this scenario, I just meant to provide a possible explanation of why those specializations are missing.
Similarly, no specialization of iterator_traits<> is provided for T* cv.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With