rel_closure_fair_total rewritten in C++