C++ и строки

C++ string classes are supposed to let you pretend that strings are first-class data. They try to abstract away the fact that strings are hard and let you act as if they were as easy as integers. Almost all C++ string classes overload the + operator so you can write s + «bar» to concatenate. But you know what? No matter how hard they try, there is no C++ string class on Earth that will let you type «foo» + «bar», because string literals in C++ are always char*’s, never strings. The abstraction has sprung a leak that the language doesn’t let you plug. (Amusingly, the history of the evolution of C++ over time can be described as a history of trying to plug the leaks in the string abstraction. Why they couldn’t just add a native string class to the language itself eludes me at the moment.)

Отсюда. Я бы сказал, это одна из самых главных проблем этого уродского языка.

Подписаться на блог
Отправить
Дальше
Мои книги