I'm a C++ novice, and I'm essentially trying to figure out if I can use an STL container as a template which stores whatever type is being passed into it. I don't know if I need to use a class template or define a unique struct or what.
Here's essentially what I have, along with some commentary on what I'd like to achieve:
std::deque<template class T> messages; <--- ???
//the goal being not to store ANY type in this deque, but to somehow
//template it for each type that needs to be stored
//e.g. a different deque for an int, bool, ADT, etc.
template<class T> bool StoreMessage(T const &messageToStore){
messages<T>.push_back(messageToStore);
}
I have no idea how to even approach this or if this is even possible, but I really don't want to have to write functions for each type that needs to be stored, because there are a lot. Or use void*. I don't want to do that either due to safety and I would still have to explicitly define how to handle each type, even though the process is going to be exactly the same.
Thanks, guys!