次の方法で共有


map::to_array (STL/CLR)

新しい配列に被制御シーケンスのコピー。

    cli::array<value_type>^ to_array();

解説

メンバー関数は、被制御シーケンス含む配列を返します。配列形式の被制御シーケンスのコピーを取得するために使用します。

使用例

// cliext_map_to_array.cpp 
// compile with: /clr 
#include <cliext/map> 
 
typedef cliext::map<wchar_t, int> Mymap; 
int main() 
    { 
    Mymap c1; 
    c1.insert(Mymap::make_value(L'a', 1)); 
    c1.insert(Mymap::make_value(L'b', 2)); 
    c1.insert(Mymap::make_value(L'c', 3)); 
 
// copy the container and modify it 
    cli::array<Mymap::value_type>^ a1 = c1.to_array(); 
 
    c1.insert(Mymap::make_value(L'd', 4)); 
    for each (Mymap::value_type elem in c1) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
 
// display the earlier array copy 
    for each (Mymap::value_type elem in a1) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
    return (0); 
    } 
 
  

必要条件

ヘッダー: <cliext/マップ>

名前空間: の cliext

参照

関連項目

map (STL/CLR)