Using C++ with D / returning a templated type from C++

vit vit at vit.vit
Wed Jul 4 17:55:32 UTC 2018


On Wednesday, 4 July 2018 at 17:32:49 UTC, Robert M. Münch wrote:
> I have the following C++ code and want to give the D/C++ 
> integration a new try:
>
> 	template<typename T> class Array {...}
> 	class myClass {...}
> 	typedef Array<myClass> myClassArray;
> 	myClassArray classA::getArray() noexcept {...}
>
> How does the D binding for this look like? I tried something 
> like this:
>  extern (C++) {
>    class Array(T){};
>    class Array(myClass) {};
>    class classA {
>      final Array(myClass) getArray(); <== COMPILER ERRORS
>    };
>  }
> But this doesn't work at all and give a bunch of comiler errors:
> Error: function declaration without return type. (Note that 
> constructors are always named this)
> Error: no identifier for declarator extern (C++) Array(myClass)
> Error: semicolon expected following function declaration
> Error: function declaration without return type. (Note that 
> constructors are always named this)
> Error: no identifier for declarator extern (C++) getArray()
>
>
> Any ideas?

final Array!myClass getArray(); <== !!!!!!!!!!!!!!!!!


More information about the Digitalmars-d-learn mailing list