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
  • 16

1 Answers1

2

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

Jean-Michaël Celerier
  • 6,602
  • 3
  • 49
  • 69