我刚读了一篇关于C ++ 0x标准的文章: http://www.softwarequalityconnection.com/2011/06/the-biggest-changes-in-c11-and-why-you-should-care/
它说 nullptr
是强类型的,这意味着它可以与整数0区分开来。
f(int);
f(char* p);
f(nullptr); // calls char* version
这一切都很好,但我很有兴趣知道标准所说的内容 nullptr
有两个指针功能:
f(char* p);
f(int* p);
f(nullptr);
我需要演员吗?并且是 nullptr
模板?
f((int*)(nullptr);
f(static_cast<int*>(nullptr));
f(nullptr<int>); // I would prefer this