Partager via


set::to_array (STL/CLR)

Copies the controlled sequence to a new array.

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

Remarks

The member function returns an array containing the controlled sequence. You use it to obtain a copy of the controlled sequence in array form.

Example

// cliext_set_to_array.cpp 
// compile with: /clr 
#include <cliext/set> 
 
typedef cliext::set<wchar_t> Myset; 
int main() 
    { 
    Myset c1; 
    c1.insert(L'a'); 
    c1.insert(L'b'); 
    c1.insert(L'c'); 
 
// copy the container and modify it 
    cli::array<wchar_t>^ a1 = c1.to_array(); 
 
    c1.insert(L'd'); 
    for each (wchar_t elem in c1) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
 
// display the earlier array copy 
    for each (wchar_t elem in a1) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
    return (0); 
    } 
 
 a b c d
 a b c

Requirements

Header: <cliext/set>

Namespace: cliext

See Also

Reference

set (STL/CLR)