Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The standard library introduces the namespace std for standards-provided declarations such as std::stringstd::vector, and std::for_each. However, it is undefined behavior to introduce new declarations in namespace std except under special circumstances. The C++ Standard, [namespace.std], paragraphs 1 and 2 [ISO/IEC 14882-2014], states:

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.

2 The behavior of a C++ program is undefined if it declares

— an explicit specialization of any member function of a standard library class template, or
— an explicit specialization of any member function template of a standard library class or class template, or
— an explicit or partial specialization of any member class template of a standard library class or class template.

...

[INCITS 2014]Issue 2139, "What Is a User-Defined Type?"
[ISO/IEC 14882-2014]Subclause 17.6.4.2.1, "Namespace std"
Subclause 17.6.4.2.2, "Namespace posix

...