Array of handles, how to

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How does one make a gc class that contains an array of handles to an array of
X-type? // comments out what I am trying to do:

public ref class c0
{
private:
static System::UInt32 c0_uid;
System::Int32 ndx;
array<System::UInt32> ^ c01 ;
// array<System::UInt32^> ^ c02 ;

public:
c0(void);
~c0(void);
System::UInt32 get_c01(System::Int32);

c0::c0(void)
{ c01 = gcnew array< System::UInt32 >(0x10);
// c02 = gcnew array< System::UInt32^ >(0x10);

for (ndx=0;ndx<0x10;ndx++){
c01[ndx] = (c0_uid << 8) + ndx;
// c02[ndx] = &(c01[ndx]);

}
c0_uid++;
}
 
Have you tried:

array<array<Uint32>^>^

Or:

array<array<String^>^>^

Unless I'm reading your request wrong.

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


| How does one make a gc class that contains an array of handles to an array
of
| X-type? // comments out what I am trying to do:
|
| public ref class c0
| {
| private:
| static System::UInt32 c0_uid;
| System::Int32 ndx;
| array<System::UInt32> ^ c01 ;
| // array<System::UInt32^> ^ c02 ;
|
| public:
| c0(void);
| ~c0(void);
| System::UInt32 get_c01(System::Int32);
|
| c0::c0(void)
| { c01 = gcnew array< System::UInt32 >(0x10);
| // c02 = gcnew array< System::UInt32^ >(0x10);
|
| for (ndx=0;ndx<0x10;ndx++){
| c01[ndx] = (c0_uid << 8) + ndx;
| // c02[ndx] = &(c01[ndx]);
|
| }
| c0_uid++;
| }
 
Keeping it as simple as I can, I had wanted to store the handles("pointers")
in c02[ndx] for the c01[ndx] value.
 
| Keeping it as simple as I can, I had wanted to store the
handles("pointers")
| in c02[ndx] for the c01[ndx] value.
Why?

It appears you want an interior_ptr:

http://msdn2.microsoft.com/en-us/library/y0fh545k.aspx

Something like (fantasy syntax):

array<interior_ptr<Uint32>>^

However! an interior_ptr can only be declared on the stack (you cannot have
an array of them, as array's are on the heap).

interior_ptr is closely related to pin_ptr, which means it effectively pins
an object, remember the GC cannot move a pinned object... (read performance
ramifications).

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


| Keeping it as simple as I can, I had wanted to store the
handles("pointers")
| in c02[ndx] for the c01[ndx] value.
|
| "Jay B. Harlow [MVP - Outlook]" wrote:
|
| > Have you tried:
| >
| > array<array<Uint32>^>^
| >
| > Or:
| >
| > array<array<String^>^>^
| >
| > Unless I'm reading your request wrong.
| >
| > --
| > Hope this helps
| > Jay [MVP - Outlook]
| > ..NET Application Architect, Enthusiast, & Evangelist
| > T.S. Bradley - http://www.tsbradley.net
| >
| >
| > | > | How does one make a gc class that contains an array of handles to an
array
| > of
| > | X-type? // comments out what I am trying to do:
| > |
| > | public ref class c0
| > | {
| > | private:
| > | static System::UInt32 c0_uid;
| > | System::Int32 ndx;
| > | array<System::UInt32> ^ c01 ;
| > | // array<System::UInt32^> ^ c02 ;
| > |
| > | public:
| > | c0(void);
| > | ~c0(void);
| > | System::UInt32 get_c01(System::Int32);
| > |
| > | c0::c0(void)
| > | { c01 = gcnew array< System::UInt32 >(0x10);
| > | // c02 = gcnew array< System::UInt32^ >(0x10);
| > |
| > | for (ndx=0;ndx<0x10;ndx++){
| > | c01[ndx] = (c0_uid << 8) + ndx;
| > | // c02[ndx] = &(c01[ndx]);
| > |
| > | }
| > | c0_uid++;
| > | }
| >
| >
| >
 
Back
Top