p0nce / d-idioms

"Effective D" without the haircut.
http://p0nce.github.io/d-idioms/
82 stars 17 forks source link

Get parent of given class at compile-time #176

Closed p0nce closed 2 years ago

p0nce commented 2 years ago
class A { }
interface I{}
class B : A, I {}

static if(is(B Parents == super) && Parents.length)
        pragma(msg, Parents[0]);

Courtesy of Adam.

and if you were doing a Phobos style template for this you'd just alias eponymous = Parents[0]