I have:
void add_all_msgs(std::deque::iterator &iter);
How can I make that function \"generic\", so it can take any kind
If you want the compiler to check whether the iterator actually refers to Message
objects, you can use a technique like the following.
template <typename InputIterator, typename ValueType>
struct AddAllMessages { };
template <typename InputIterator>
struct AddAllMessages<InputIterator, Message> {
static void execute(const InputIterator &it) {
// ...
}
};
template <typename InputIterator>
void add_all_msgs(const InputIterator &it) {
AddAllMessages<InputIterator,
typename std::iterator_traits<InputIterator>::value_type>::execute(it);
}