C++ implementation of fan_out_instrument.lua