template opDispatch(string name) {
static if (is(typeof(__traits(getMember, this._obj, name)) == function)) {
// non template function
auto ref opDispatch(this X, Args...)(Args args) {
return mixin("this._obj." ~ name ~ "(args)");
}
auto ref opDispatch(this X, Args...)(Args args) const {
return mixin("this._obj." ~ name ~ "(args)");
}
} else static if (is(typeof(mixin("this._obj." ~ name))) || __traits(getOverloads, this._obj, name).length != 0) {
// field or property function
@property
auto ref opDispatch(this X)() {
return mixin("this._obj." ~ name);
}
@property
auto ref opDispatch(this X, V)(auto ref V v) {
return mixin("this._obj." ~ name ~ " = v");
}
} else {
// member template
template opDispatch(T...) {
auto ref opDispatch(this X, Args...)(Args args) {
return mixin("this._obj." ~ name ~ "!(T)(args)");
}
}
}
}