Users are allowed to add explicit specializations to the std namespace. However, there are a few templates that I am explicitly forbidden from specializing.
What templates can and can’t I specialize?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Quoting loosely from the standard:
numeric_limitsshall not be specialized for non-arithmetic standard types (e.g.complex<T>)"[S]pecializations of
shared_ptrshall be CopyConstructible, CopyAssignable, and LessThanComparable [and] convertible tobool.""Specializations of
weak_ptrshall be CopyConstructible and CopyAssignable.""[T]emplate specializations [of
std::hash] shall meet the requirements of class template hash."Anything in
<type_traits>: "The behavior of a program that adds specializations for any of the class templates defined in this subclause is undefined unless otherwise specified." (only some specializations ofcommon_typeare explicitly allowed)Locales have certain required specializations.
All specializations of
istreambuf_iteratorshall have a trivial copy constructor, a constexpr default constructor, and a trivial destructor."The effect of instantiating the class template
complexfor any type other than float, double, or long double is unspecified." I take it that means that defining such other specializations is pointless."Specializations and instantiations of the
atomictemplate shall have a deleted copy constructor, a deleted copy assignment operator, and a constexpr value constructor.""The class templates
unary_functionandbinary_functionare deprecated. A program shall not declare specializations of these templates."And of course the overarching clause 17.6.4.2.1, sentence 1 (thanks @sehe and @curiousguy):
And sentence 2: