C++ member function translations
Christian Kamm
kamm.incasoftware at shift-at-left-and-remove-this.de
Fri Jul 27 01:55:20 PDT 2007
> Can someone who's figured this out tell me what the translations for the
> following C++ member function signatures would be in D 2.0?
I don't think literal translations are possible, especially since the
notions of constness in D and C++ are so different. Here's a try ignoring
the basic differences (transitivity...) anyway. I'll split the questions
differently though, easy ones first.
? How to return const Foo& and Foo& if Foo is a class?
const(Foo) and Foo should do it.
? How to pass Bar& if Bar is a struct?
ref Bar
? How to return const Foo& and Foo& if Foo is a struct?
Can't return ref parameters, so Foo* and const(Foo*) seem to be the only
option.
? How to pass const Bar& if Bar is a struct?
ref const(Bar) currently causes a compiler segfault (bug 1319), but I'm not
sure if it'd have the right behaviour anyway. So it's const(Bar*) again...
That's all not really satisfacty. If there are better options, I'd like to
know them too.
Regards,
Christian
More information about the Digitalmars-d-learn
mailing list