Edward Diener wrote:
In the doc regarding __value classes, under Primitive Types, I read:
"Generally, the C++ types and their __value class equivalents are
interchangeable in Managed Extensions."
What exactly does this mean ?
It means that you can do the following:
int x = 42;
System::Int32 y = x;
int z = y;
Basically, int and System::Int32 are exactly the same type. In fact, when
you type System::Int32 in a program, the compiler diagnostics will say "int"
instead.
The "generally" comes in when GC'ness of a type matters. This appears in two
contexts: (1) default meaning for a pointer, and (2) default meaning for an
array. The C++ type is assumed to have no GC'ness, whereas the __value class
equivalent does have GC'ness.
If a type T has GC'ness, then the declaration "T*" defaults to a __gc
pointer. If a type does not have GC'ness, then the declaration "T*" defaults
to a native pointer. To convert from a __gc pointer to a native pointer
requires pinning.
If a type T has GC'ness, then the declaration "T arr[]" defaults to a
System::Array of T. If a type T does not have GC'ness, then the declaration
"T arr[]" is a native C-style array.
Based on that summary, it should be easy to make sense of this when you read
other parts of the Managed Extenstions spec.
Hope that helps!
--
Brandon Bray
http://blogs.gotdotnet.com/branbray/
This posting is provided AS IS with no warranties, and confers no rights.