On Tuesday, 13 November 2018 at 07:29:30 UTC, Ali Çehreli wrote:
On 11/12/2018 11:10 PM, Jamie wrote:
> I would like my class to inherit from one of two classes ...
> Is this possible? I can't get it to work in the way I'm
showing above.
> Cheers
I got it working inside an eponymous template. D is pretty cool
actually. :)
enum OPTION
{
FALSE = 0.,
TRUE = 1.
}
class One
{}
class Two
{}
template Top(OPTION option) {
static if (option == OPTION.TRUE) {
alias Base = One;
} else {
alias Base = Two;
}
class Top : Base
{}
}
void main() {
auto a = new Top!(OPTION.FALSE);
auto b = new Top!(OPTION.TRUE);
}
Ali
Wow that's nifty, thanks very much! And thanks for the speedy
response