Binding C++ Value Type (Templates)

Daniel Murphy via Digitalmars-d digitalmars-d at puremagic.com
Fri Feb 13 10:40:58 PST 2015


"Benjamin Thaut"  wrote in message 
news:mzgymsfzrxbvffgcfzxz at forum.dlang.org...

> There are currently two problems with binding c++ value types and c++ 
> value type templates.
>
> 1. Semantics are somewhat different. Copying / constructor / destructing / 
> operator overloading is a issue.
> 2. Only templates which are instantiated on the c++ side can be used.
>
> Now it would be nice if I could tell a type, that it should be mangled 
> like a C++ type but only if it is used in a C++ function signature. The 
> entire type would still be implemented on the D side and the implementor 
> would have to garantuee that the binary layout is the same as on the C++ 
> side.

You don't need to tell the type anything, this is how all structs work by 
default.  One thing you need to be very careful about is making sure that 
both languages see the struct as POD or non-POD, otherwise they may disagree 
on how to pass it to/return it from functions.

What problems have you been having with this approach? 



More information about the Digitalmars-d mailing list