Is NULL defined as nullptr in C++11?

后端 未结 4 1603
你的背包
你的背包 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 20:08

    No, NULL is still the same as before. Too many people used the NULL macro in surprising ways, redefining it to nullptr would have broken a lot of code.

    To elaborate: people have used NULL for example for many kinds of handle typedefs. If the real type behind such a typedef is not a pointer, defining NULL as nullptr would be a problem. Also, it seems some people have indeed used NULL to initialize numeric types.

    At least that is what Microsoft found when they added the nullptr to MSVC10, and why they decided to keep NULL as it always was. Other compilers might choose a different path, but I don't think they would.

提交回复
热议问题