Revert "foreach directly takes only VoidFunction in the interface"

This reverts commit 927d242360da7e6104aff70e1711b2431e2be100.