list::assign (STL/CLR)
Replaces all elements.
void assign(size_type count, value_type val);
template<typename InIt>
void assign(InIt first, InIt last);
void assign(System::Collections::Generic::IEnumerable<Value>^ right);
Parameters
count
Number of elements to insert.first
Beginning of range to insert.last
End of range to insert.right
Enumeration to insert.val
Value of the element to insert.
Remarks
The first member function replaces the controlled sequence with a repetition of count elements of value val. You use it to fill the container with elements all having the same value.
If InIt is an integer type, the second member function behaves the same as assign((size_type)first, (value_type)last). Otherwise, it replaces the controlled sequence with the sequence [first, last). You use it to make the controlled sequence a copy another sequence.
The third member function replaces the controlled sequence with the sequence designated by the enumerator right. You use it to make the controlled sequence a copy of a sequence described by an enumerator.
Example
// cliext_list_assign.cpp
// compile with: /clr
#include <cliext/list>
int main()
{
cliext::list<wchar_t> c1;
c1.push_back(L'a');
c1.push_back(L'b');
c1.push_back(L'c');
// assign a repetition of values
cliext::list<wchar_t> c2;
c2.assign(6, L'x');
for each (wchar_t elem in c2)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
// assign an iterator range
cliext::list<wchar_t>::iterator it = c1.end();
c2.assign(c1.begin(), --it);
for each (wchar_t elem in c2)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
// assign an enumeration
c2.assign( // NOTE: cast is not needed
(System::Collections::Generic::IEnumerable<wchar_t>^)%c1);
for each (wchar_t elem in c2)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
return (0);
}
x x x x x x
a b
a b c
Requirements
Header: <cliext/list>
Namespace: cliext