Any invalid use of String (C ++)

I really checked on google for this, but I usually found the opposite. Is there any drawback in C ++ for using string string strings instead of C strings or some kind of character arrays? maybe a little slower?

Feel free to call me a hoax, however I searched and could not find anything (altho im sure someone asked)

+3
source share
4 answers

In fact, there is no significant drawback if it is assumed that the vendor's implementation std::stringis competent. The class is std::stringunlikely to be slower than simple C-lines with compiler optimization turned on.

, C (, API, const char*), std::string::c_str().

, , , COW . (. std::string )

++ 0x, ++ 03 , -, std::string.

, , ++ 03 std::string . , , std::string. , , ++ 03, , , , 1) ( ) std::string , 2) c++ 0x, .

+11

, , - (, /). , new, STL. char .

+3

, . , , string , , .

+1

, . , C-, C-.

... , C- , ...

stdlib.

0

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


All Articles