Adding types to the std namespace

后端 未结 7 841
孤城傲影
孤城傲影 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条回答
  •  半阙折子戏
    2020-11-28 16:16

    [C++11: 17.6.4.2.1/1]: The behavior of a C++ program is undefined if it adds declarations or definitions to namespace std or to a namespace within namespace std unless otherwise specified. A program may add a template specialization for any standard library template to namespace std only if the declaration depends on a user-defined type and the specialization meets the standard library requirements for the original template and is not explicitly prohibited.

提交回复
热议问题