hash_map::operator= (STL/CLR)

控件替换序列。

    hash_map<Key, Mapped>% operator=(hash_map<Key, Mapped>% right);

参数

  • right
    复制的容器。

备注

运算符将 right 对该对象的成员,然后返回 *this。 使用它将控制的序列复制在 right中替换控件序列。

示例

// cliext_hash_map_operator_as.cpp 
// compile with: /clr 
#include <cliext/hash_map> 
 
typedef cliext::hash_map<wchar_t, int> Myhash_map; 
int main() 
    { 
    Myhash_map c1; 
    c1.insert(Myhash_map::make_value(L'a', 1)); 
    c1.insert(Myhash_map::make_value(L'b', 2)); 
    c1.insert(Myhash_map::make_value(L'c', 3)); 
 
// display contents " [a 1] [b 2] [c 3]" 
    for each (Myhash_map::value_type elem in c1) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
 
// assign to a new container 
    Myhash_map c2; 
    c2 = c1; 
// display contents " [a 1] [b 2] [c 3]" 
    for each (Myhash_map::value_type elem in c2) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
    return (0); 
    } 
 
  

要求

页眉: <cliext/hash_map>

命名空间: cliext

请参见

参考

hash_map (STL/CLR)