Is NULL defined as nullptr in C++11?

后端 未结 4 1606
你的背包
你的背包 2020-12-18 19:05

Will C++11 implementations define NULLas nullptr?

Would this be prescribed by the new C++ standard?

4条回答
  •  心在旅途
    2020-12-18 19:57

    From the horse's mouth

    C.3.2.4 Macro NULL [diff.null]

    1/ The macro NULL, defined in any of , , , , , , or , is an implementation-defined C++ null pointer constant in this International Standard (18.2).

    It is up to each implementation to provide its own definition, gcc if I recall correctly defines it to __nullptr for which it has special checks (verifies that it is not used in arithmetic contexts for example).

    So it is possible to define it as nullptr, you will have to check your compiler/Standard Library documentation to see what has been done.

提交回复
热议问题