SD-8: Standard Library Compatibility

Doc. No.: SD-8
Date: 2020-03-08
Reply to: Bryce Lelbach

Standard Library Compatibility

For a sufficiently clever user, effectively any change we make to the standard library will be a breaking change. In a few instances, the standard itself is clear about what users are not allowed to do ("do not take the address of member functions of standard types", "do not add new names into namespace std") - those restrictions are not widely understood, are incomplete, and leave completely unclear why those rules are in place. In keeping with general discussions of  compatibility, and as mentioned in P0684, we should be clear to users about what does and does not constitute supported use of the C++ standard library. What rights does the committee reserve in order to make changes to the standard library in the future?

Note in particular that users of the standard are not special in this: abuse of these rules is generally bad usage for most libraries.

Rights the Standard Library Reserves for Itself

Primarily, the standard reserves the right to:

  • Add new names to namespace std, to any namespace reserved for future standardization (for example std2; see [namespace.future] for more details), and to any sub-namespaces of those namespaces
  • Add new names to any entity within any reserved namespace, including but not limited to
    o Functions (this includes new member functions and overloads to existing functions)
    o Enumerations
    o Namespaces
    o Aliases (using, typedef, etc.)
    o Classes (struct/class/union)
    o Concepts
    o Variables
  • Add new default arguments to functions and templates
  • Change return-types of functions in compatible ways (void to anything, numeric types in a widening fashion, etc).
  • Make changes to existing interfaces in a fashion that will be backward compatible, if those interfaces are solely used to instantiate types and invoke functions. Implementation details (the primary name of a type, the implementation details for a function callable) may not be depended upon.