Is the `std :: litals` namespace usage safe?

It is generally considered bad practiceusing namespace in a global area . However, according to cppreference , identifiers that do not begin with an underscore ( ) are reserved for the standard library in the case of custom literals._

identifier to use as the ud suffix for user literals that will call this function. You must start with the underscore _: suffixes that do not begin with the underscore are reserved for literals provided by the standard library.

Does this mean that I can safely execute using namespace std::literals;in a global area?

+6
source share
2 answers

From the point of view of the standard, when they say that some names are reserved by the standard library, I would interpret this as a guarantee of a certain behavior if you violate the agreement. On the other hand, some compilers may not hold you accountable for violating a prescribed agreement. For example, gccit gives a warning, not an error, so as not to start the literal identifier of the operator with an underline.

The best wording here is not whether inclusion

using namespace std::literals;

- , . using namespace foo - , , .

, , . , . , , ( , ).

0

. ; ( Boost). : , namespace std, _.

: , _, . , , , .

, , , . , " using "? . . .cpp , . . :

using namespace std::literals .

+3

All Articles