다음을 통해 공유


make_collection (STL/CLR)

Make a range_adapter from an iterator pair.

template<typename Iter>
    range_adapter<Iter> make_collection(Iter first, Iter last);

Parameters

  • Iter
    The type of the wrapped iterators.

  • first
    First iterator to wrap.

  • last
    Second iterator to wrap.

Remarks

The template function returns gcnew range_adapter<Iter>(first, last). You use it to construct a range_adapter<Iter> object from a pair of iterators.

Example

// 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); 
    } 
 
 a b c
Count = 3
IsSynchronized = False
SyncRoot not nullptr = True
 | a b c |

Requirements

Header: <cliext/adapter>

Namespace: cliext

See Also

Reference

range_adapter (STL/CLR)