I've written an asynchronous job queue class which has been working nicely for ages. It uses a std::vector
as the underlying collection to keep jobs in and then processes them later as you might expect. When I add a job it does a push_back
on this vector
.
Recently I decided that I wanted to templatize the underlying collection type that it uses and the with way I've written it, this should be very simple. It's now declared thus:
template<typename J, typename CollectionT = std::vector<J>>
class async_jobqueue
{
public:
There's just one snag, for vectorish type containers I want to push things onto the end of the collection and call push_back
, for settish type containers I'll want to call insert
. How can I make a compile decision about which to call? Or is there a handy adapter I can use?