structConvert

Copies members of the same name from <From> to <To>.

Given a variable in <To> called 'example_var', if a static convert function in <To> exists with the name 'convert_example_var', then this function will be called and no automatic conversion will happen for that variable. The function must have one of the following signatures:

void function ( ref <From>, ref <To>, void[] delegate ( size_t ) )
void function ( ref <From>, ref <To> )

The delegate passed to the first version can be used to allocate temporary buffers that the convert function might need in order to do its converting.

If no convert function exists and the types differ, various things happen:

* For structs it calls this function again * For dynamic arrays, a temporary array of the same length is created and this function is called for every element of the array * For static arrays the same happens, just without a temporary allocation

If the types are the same a simple assignment will be done. The types have to match exactly, implicit conversions are not supported.

It is an error if a variable in <To> doesn't exist in <From> and no convert function for it exists,

Note: Dynamic arrays of the same type will actually reference the same memory where as arrays of similar types that were converted use memory provided by the requestBuffer delegate.

Template Parameters: From = type we're copying from To = type we're copying to

void
structConvert
(
From
To
)
(
ref From from
,
out To to
,
void[] delegate
(
size_t
)
requestBuffer = 
(
size_t n
)
)

Parameters

from From

instance we're copying from

to To

instance we're copying to

requestBuffer void[] delegate
(
size_t
)

delegate to request temporary buffers used during conversion.

Meta