I have been reading through the ManagedExtensionsSpec.doc file and I
thought something was not clear.
If I have a __value class (really a __value struct but that shouldn't
make a difference) and I want a non-variable-size array of them, are
there any advantages/disadvantages to using a __gc array versus a __nogc
array?
Section 4.5.3 (__gc and __nogc Keywords and Arrays) says:
The keywords __gc and __nogc can be applied to arrays whose element
type is a C++ primitive type or the corresponding runtime __value
type (Section 5.1).
but it doesn't mention user-defined __value types.
On
http://msdn.microsoft.com/library/de...nagedtypes.asp
it says:
GC and value types cannot:
* Contain pointers to other managed types
So, reading this, it seems that a __gc array should not be allowed in a
__value type.
In other words, is there anything wrong with this:
static const int max_contours = 5;
__value struct Contours {
int num_contours;
__value struct ContourInfo {
double lower_bound;
int r;
int g;
int b;
} contours __nogc[max_contours];
};
as opposed to doing it like this:
static const int max_contours = 5;
__value struct Contours {
int num_contours;
__value struct ContourInfo {
double lower_bound;
int r;
int g;
int b;
};
ContourInfo contours[];
Contours()
: contours(new ContourInfo[max_contours])
{ }
};
--
Marcus Kwok
Replace 'invalid' with 'net' to reply