make_collection (STL/CLR)
由一個 Iterator 而使 range_adapter 。
template<typename Iter>
range_adapter<Iter> make_collection(Iter first, Iter last);
參數
Iter
包裝的 Iterator 的型別。首先
包裝的第一個 Iterator。last
第二個包裝的 Iterator。
備註
樣板函式會傳回 gcnew range_adapter<Iter>(first,last)。 您可以使用它從一組的 range_adapter<Iter> 物件 Iterator。
範例
// cliext_make_collection.cpp
// compile with: /clr
#include <cliext/adapter>
#include <cliext/deque>
typedef cliext::deque<wchar_t> Mycont;
typedef cliext::range_adapter<Mycont::iterator> Myrange;
int main()
{
cliext::deque<wchar_t> d1;
d1.push_back(L'a');
d1.push_back(L'b');
d1.push_back(L'c');
// display contents " a b c"
for each (wchar_t elem in d1)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
System::Collections::ICollection^ p1 =
cliext::make_collection(d1.begin(), d1.end());
System::Console::WriteLine("Count = {0}", p1->Count);
System::Console::WriteLine("IsSynchronized = {0}",
p1->IsSynchronized);
System::Console::WriteLine("SyncRoot not nullptr = {0}",
p1->SyncRoot != nullptr);
// copy the sequence
cli::array<System::Object^>^ a1 = gcnew cli::array<System::Object^>(5);
a1[0] = L'|';
p1->CopyTo(a1, 1);
a1[4] = L'|';
for each (wchar_t elem in a1)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
return (0);
}
需求
標題: <cliext/配接器>
命名空間: cliext