I have been looking at a library implementation of nullptr as shown in A name for the null pointer: nullptr (revision 2) (warning: PDF).
One criticism leveled against it is that:
It seems to be that this can be solved simply by naming the class, e.g., nullptr_t. This allows one to create more nullptr_t objects other than nullptr, but since they are all equivalent anyway, it seemes a small price to pay for far more readable error messages. What other problems do you see with turning this anonymous class into the nullptr_t class?Experiments with several popular existing compilers show that it generates poor and/or misleading compiler diagnostics for several of the common use cases described in section 2. (Examples include: "no conversion from 'const' to 'int'"; "no suitable conversion function from 'const class <unnamed>' to 'int' exists"; "a template argument may not reference an unnamed type"; "no operator '==' matches these operands, operand types are: int == const class <unnamed>".) We believe that compilers will still need to add special knowledge of nullptr in order to provide quality diagnostics for common use cases.