1
typedef std::basic_string<wchar_t,          std::char_traits<wchar_t>, TestStringAllocator<wchar_t> >       TestString;

So is it a "basic_string" or is it a "wchar_t"

Please let me understand, I need to do conversions and don't know what the type of TestString is.

Thanks.

2 Answers2

1

In this case TestString is just std::wstring with custom allocator defined TestStringAllocator.

Most probably this is used to inspect how allocator works and how std::basic_string is using that. Some time ago I used something similar to investigate if std::string_stream is optimized (is not).

Since you didn't provided definition of TestStringAllocator it is impossible to tell what is its purpose.

Marek R
  • 32,568
  • 6
  • 55
  • 140
0

Just as the code says, the type of TestString is:

std::basic_string<wchar_t, std::char_traits<wchar_t>, TestStringAllocator<wchar_t>>

It's a string, not a character.

Blindy
  • 65,249
  • 10
  • 91
  • 131
  • So is it a basic_string or a wchar_t? What does everything in <> mean? –  Oct 29 '20 at 17:16
  • 1
    It's a string **of** `wchar_t`. Used by folk who haven't embraced the beauty of UTF-8 yet ;-) Informally you can think of it as a "Unicode" string, but that term is not really particularly helpful. – Bathsheba Oct 29 '20 at 17:18
  • @Bob : *What does everything in <> mean?* Those are [template arguments](https://en.cppreference.com/w/cpp/language/templates) – user4581301 Oct 29 '20 at 17:25