"Now, I want to put all types into a single vector."
When a template is instantiated, a new type is created. For instance:
1 2
templateclass TalkFirmware<int>; // TalkFirmware<int> is a type.
templateclass TalkFirmware<char>; // TalkFirmware<char> is a type.
The two above types are completely different. With that in mind, the std::vector would only be able to store a single TalkFirmware type. It is possible to store multiple types with inheritance, however:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
struct Base
{
// ...
};
template <typename T>
struct Child : public Base
{
Child(const T &Init = T()) : Member__(Init) { }
T Member__;
};
int main()
{
std::vector<Base *> MyVector;
MyVector.push_back(&Child<int>(44));
MyVector.push_back(&Child<float>(1.3F));
}
The problem with this is that it's so restrictive, it's useless.