C ++ When can I expand the `std` namespace?

The thread on SO says the extension stdis UB (well, if you are, of course, not standard authors). But from time to time stdhappily expands. When is everything alright?

+4
source share
2 answers

The only time you can add a definition to a namespace stdis to specialize a template that already exists in the namespace and explicitly creates an instance of the template. However, only if they depend on a user-defined type.

[namespace.std] (standard draft):

  • ++ undefined, std std, . std , , .

  • ++ undefined,

    (2.1) -

    (2.2) -

    (2.3) .

    , , , .


, : std::hash std::iterator_traits.

+5

.

: std::hash std::unordered_map

+2

Source: https://habr.com/ru/post/1663328/


All Articles