Any chance to avoid monitor field in my class?

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 14 07:08:52 PDT 2014


On 05/14/2014 04:15 AM, Yuriy wrote:
 > On Wednesday, 14 May 2014 at 10:21:00 UTC, Dejan Lekic wrote:
 >> that should not compile at all. Perhaps you thought extern(C++)
 >> interface MyClass(T) ?
 > Ok, how about this one?
 > http://dpaste.dzfl.pl/04655ff6ddfd
 > It doesn't compile either.

extern(C++) interface I
{
     string hi();
}

extern(C++) class A(T) : I
{
     override string hi()
     {
         return "asdf";
     }
}

void main()
{
     A!string a;
}

/d208/f532.d(9): Error: class f532.A!(string).A cannot create C++ 
classes /d208/f532.d(19): Error: template instance f532.A!(string) error 
instantiating

Yeah, that is a documented limitation when using C++ code. C++ templates 
cannot be used in D. "C++ Templates" here:

   http://dlang.org/cpp_interface.html

Ali



More information about the Digitalmars-d-learn mailing list