I want to accomplish the following:
Entity e;
e.AddComponent<CPosition>(128, 128); //method should instantiate a new CPosition(128,128)
e.AddComponent<CSprite>(some, other, args); //etc
The important part is the AddComponent method. It should attempt to construct the generic type with the arguments passed. I believe C++11’s variadic templates to forward the arguments to the constructor. However, I do not have access to this functionality yet (VS2010).
Does anyone have any idea on how to do this?
Write a bunch of overloads, each taking a different number of parameters.