I wrote an asynchronous job queue class that has been working fine for ages. It uses it std::vectoras a base collection for saving tasks, and then processes them later, as you might expect. When I add a task, he does push_backit vector.
I recently decided that I want to plan the template type of the collection that it uses, and the way I wrote it, it should be very simple. Now it is declared this way:
template<typename J, typename CollectionT = std::vector<J>>
class async_jobqueue
{
public:
There is only one catch, for containers with a vector type I want to push things to the end of the collection and call push_back, for containers of type types I want to call insert. How can I make a compilation decision on how to call? Or is there a convenient adapter that I can use?
source
share