You can always put a constant that defines compilation as template arguments. So here is what it would be:
template <typename T, typename R, RT::* member> R& SetVal(T& t, const R& value) { t.*member = value; return t.*member; } struct A { int a; }; int main() { A a; SetVal<A,int,&A::a>(a, 10); return 0; }
source share