我看到微軟的stddef.h
定義nullptr_t
這樣的:'nullptr_t`應該是全局命名空間的一部分嗎?
namespace std
{
typedef decltype(__nullptr) nullptr_t;
}
using ::std::nullptr_t;
的using
decleration注入nullptr_t
到全局命名空間。我無法在標準中找到任何說明應該完成的事情。
我還看到在GCC
nullptr_t
不在全局命名空間中。
這兩種實現都可以被允許或者是其中的一個bug?
我的不好,GCC的行爲與CL相同。
編輯:用cstddef
同樣的情況,下面編譯罰款與VC(online too)。
#include <cstddef>
int main()
{
nullptr_t nil = nullptr;
}
'使用:: std :: nullptr_t;'和'使用std :: nullptr_t;'有區別嗎?很好的問題btw。 – gsamaras
@gsamaras我不認爲有什麼區別。 – Motti
在這方面沒有區別。如果你有'namespace foo {namespace std {using nullptr_t = int}使用std :: nullptr_t; }'。 –