Partager via


collection_adapter::collection_adapter (STL/CLR)

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at collection_adapter::collection_adapter (STL/CLR).

Constructs an adapter object.

Syntax

collection_adapter();  
collection_adapter(collection_adapter<Coll>% right);  
collection_adapter(collection_adapter<Coll>^ right);  
collection_adapter(Coll^ collection);  

Parameters

collection
BCL handle to wrap.

right
Object to copy.

Remarks

The constructor:

collection_adapter();

initializes the stored handle with nullptr.

The constructor:

collection_adapter(collection_adapter<Coll>% right);

initializes the stored handle with right``.collection_adapter::base (STL/CLR)().

The constructor:

collection_adapter(collection_adapter<Coll>^ right);

initializes the stored handle with right``->collection_adapter::base (STL/CLR)().

The constructor:

collection_adapter(Coll^ collection);

initializes the stored handle with with collection.

Example

// cliext_collection_adapter_construct.cpp   
// compile with: /clr   
#include <cliext/adapter>   
#include <cliext/deque>   
  
typedef cliext::collection_adapter<   
    System::Collections::ICollection> Mycoll;   
int main()   
    {   
    cliext::deque<wchar_t> d6x(6, L'x');   
  
// construct an empty container   
    Mycoll c1;   
    System::Console::WriteLine("base() null = {0}", c1.base() == nullptr);   
  
// construct with a handle   
    Mycoll c2(%d6x);   
    for each (wchar_t elem in c2)   
        System::Console::Write(" {0}", elem);   
    System::Console::WriteLine();   
  
// construct by copying another container   
    Mycoll c3(c2);   
    for each (wchar_t elem in c3)   
        System::Console::Write(" {0}", elem);   
    System::Console::WriteLine();   
  
// construct by copying a container handle   
    Mycoll c4(%c3);   
    for each (wchar_t elem in c4)   
        System::Console::Write(" {0}", elem);   
    System::Console::WriteLine();   
  
    return (0);   
    }  
  
base
() null = True  
 x x x x x x  
 x x x x x x  
 x x x x x x  

Requirements

Header: <cliext/adapter>

Namespace: cliext

See Also

collection_adapter (STL/CLR)
collection_adapter::operator= (STL/CLR)