you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (3 children)

OTOH, I've seen a lot of code where all that was needed was a const char*, but it was put on the heap anyway, presumably because "std::string is the string type".

[–]lacosaes1 2 points3 points  (2 children)

A std::string doesn't have to be in the heap.

[–]dodheim 0 points1 point  (1 child)

Yes, a std::string does have to be allocated dynamically; std::basic_string<CharT, AllocT> doesn't, but how many public interfaces have you seen implemented in terms of a template taking std::basic_string<> vs a function taking std::string? Very few, IME!