[Issue 17462] Order of base interfaces affects compiler behavior
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jan 15 19:23:29 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=17462
--- Comment #4 from Andrei Alexandrescu <andrei at erdani.com> ---
The following C++ equivalent does require the additional implementation
(uncomment code to get it to compile):
--------------------
class Marker {};
class Foo { public: virtual void foo() = 0; };
class FooMarked : public Foo, public Marker {};
class MarkedFoo : public Marker, public Foo {};
class Base : public Foo { virtual void foo() {} };
class Derived1 : public Base, public FooMarked {
//virtual void foo() {}
};
class Derived2 : public Base, public MarkedFoo {
//virtual void foo() {}
};
int main() {
auto d1 = new Derived1;
auto d2 = new Derived2;
}
--------------------
However, this other code, which arguably is closer in spirit, does work:
--------------------
class Marker {};
class Foo { public: virtual void foo() = 0; };
class FooMarked : virtual public Foo, public Marker {};
class MarkedFoo : public Marker, virtual public Foo {};
class Base : virtual public Foo { virtual void foo() {} };
class Derived1 : public Base, public FooMarked {};
class Derived2 : public Base, public MarkedFoo {};
int main() {
auto d1 = new Derived1;
auto d2 = new Derived2;
}
--------------------
--
More information about the Digitalmars-d-bugs
mailing list