Solved by Vinod in post #2 
              
              
                I am not sure if you have any specific requirement to use vector of modules. In C++ API, we have ModuleList which could be used for this purpose. 
Hopefully this can meet your requirement