Adding types to the std namespace

后端 未结 7 842
孤城傲影
孤城傲影 2020-11-28 15:34

Is it acceptable to add types to the std namespace. For example, I want a TCHAR-friendly string, so is the following acceptable?

#include 

        
7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 16:18

    No ... part of the point of a namespace is to prevent name collisions on upgrade.

    If you add things to the std namespace, then your code might break with the next release of the library if they decide to add something with the same name.

提交回复
热议问题