wstring

ワイド文字の文字列を宣言します。wstring は wchar_t の文字列データの格納にテンプレート クラス basic_string を特化する typedef です。wstringbasic_string のクラスの機能を継承しています; これは、演算子とメソッドが含まれています。

basic_string を特化する他の [文字列]typedef は、u16stringu32stringが含まれます。詳細については、「<string> メンバー」を参照してください。

typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;

使用例

// string_wstring.cpp
// compile with: /EHsc
#include <string>
#include <iostream>

int main( ) 
{
   using namespace std;
   // Equivalent ways to declare an object of type
   // basic_string <wchar_t>
   const basic_string <wchar_t> s1 ( L"abc" );
   wstring s2 ( L"abc" );   // Uses the typedef for wstring

   // Comparison between two objects of type basic_string <wchar_t>
   if ( s1 == s2 )
      cout << "The strings s1 & s2 are equal." << endl;
   else
      cout << "The strings s1 & s2 are not equal." << endl;
}
  

必要条件

ヘッダー: <string>

名前空間: std

参照

関連項目

basic_string Class