Why aren't C++14 standard-defined literals in the global namespace by default?

前端 未结 3 1697
你的背包
你的背包 2021-01-01 14:22

C++14 includes standard-defined literals for, amongst other things, std::string and various timespans from the header.

To us

3条回答
  •  太阳男子
    2021-01-01 14:35

    There already are two UDLs named s: one for strings and one for seconds. Due to the understandably terse names of suffixes, they chronically suffer from name conflicts, so pouring all of them into one namespace cannot go well for long. Hence it was decided that they be put into inline namespaces, which allow for both unambiguous (using namespace std::literals::chrono_literals) and simple using directives (using namespace std).

提交回复
热议问题