Is there any reason to put the "" operator in std :: litals :: string_literals?

I am very surprised to find that this code does not compile (it is assumed that we use the C ++ 14 compiler):

std::cout << "hello world!\n"s;

The error shown by ideone is below :

cannot find string literal operator "operator" "s"

Fortunately, it’s pretty easy to fix the statement using:

using namespace std::literals::string_literals;
std::cout << "hello world!\n"s; // Compiles!

I am wondering if there is a reason for placing standard string user literals in a different namespace than itself std::string; I thought about it, and I can not understand the reason.

It is impossible to run into operator""swith std::chrono, because they work with different types:

auto ten_seconds = 10s; // ten seconds
auto some_string = "some string"s; // some string

, resason , , , '_' underscore:

: , '_',

, , - std::literals::string_literals?

.

+4

All Articles