<p><br>
On May 18, 2013 11:25 PM, "Igor Stepanov" <<a href="mailto:wazar.leollone@yahoo.com">wazar.leollone@yahoo.com</a>> wrote:<br>
><br>
> At the current time D have powerful mechanism of access to C++ classes.<br>
> For access to methods of C++ classes (virtual and not) we can use extern(C++) interface.<br>
><br>
> //С++<br>
><br>
> class CPPTest1<br>
> {<br>
>     int a;<br>
>     int b;<br>
>   public:<br>
>     virtual int boom();<br>
>     int fun();<br>
>     static int gun();<br>
>     CPPTest1(int);<br>
>     virtual ~CPPTest1();<br>
>     int& operator[](size_t);<br>
> };<br>
><br>
> class CPPTest2: public CPPTest1<br>
> {<br>
>     int boom();<br>
> };<br>
><br>
> //D<br>
> extern(C++)interface CPPTest1<br>
> {<br>
>     int boom();<br>
>     static int gun();<br>
>     final int fun();<br>
> }<br>
><br>
> extern(C++)interface CPPTest2: CPPTest1<br>
> {<br>
>     //int boom();<br>
> }<br>
><br>
><br>
><br>
> As a rule, non-static fields are not public in C++ classes and is not part of interface. Thus the most of C++ classes can be bound without any glue c++ code.<br>
> However D dont support C++ overloaded operators and constructors. Yes, we cannot make mapping C++ operators to D operators and C++ constructors to D constructors). Nonetheless С++ operators and constructors are the simple C++ functions or methods with special mangling. Thus I've suggest next mechanism:<br>

> Allow special pragma(cppSymbol, string_arg), when string_arg is the name of c++ thing.<br>
> Example:<br>
><br>
> extern(C++)interface CPPTest1<br>
> {<br>
>     int boom();<br>
>     static int gun();<br>
>     final int fun();<br>
>     ///!!!!<br>
>     pragma(cppSymbol, "constructor") final void ctor(int); //linked with CPPTest1(int);<br>
>     pragma(cppSymbol, "destructor") void dtor(); //linked with virtual ~CPPTest1();<br>
>     pragma(cppSymbol, "[]") ref int indexOf(size_t); //linked with int& operator[](size_t);<br>
> }<br>
><br>
> This pragma must apply to the function (or method), use natural C++ mangle, but set operatror or constructor or destructor mangled name instead of function name.<br>
><br>
> Is it useful idea?</p>
<p>No.</p>
<p>Regards<br>
-- <br>
Iain Buclaw</p>
<p>*(p < e ? p++ : p) = (c & 0x0f) + '0';</p>