1

typedef basic_string<char> string;

All the std::string facilities in the standard library are using char. Why is that? Although all the characters of the ASCII table (128) fit into the range of a char (-128 to 127), many other character encodings are using 8-bits for representation.

What is the advantage of having 'negative' values in a string of chars?

Jan Müller
  • 413
  • 3
  • 18

1 Answers1

1

String literals are of type const char*, so it would require a O(n) conversion when doing std::string("fooo").

Jean-Michaël Celerier
  • 7,412
  • 3
  • 54
  • 75