Use foreach to generate C++ implicit rules