Way to get rid of dummy variable

I have this basic sort function for containers with non-random access iterators:
1
2
3
4
5
6
7
8
9
template <typename InIter, class Comp>
void sort(InIter curr, InIter end, Comp comp){
    auto deduced_t = *curr;
    std::vector<decltype(deduced_t)> catalyst;
    InIter begin(curr);
    while(curr != end) catalyst.push_back(*(curr++));
    std::sort(catalyst.begin(), catalyst.end(), comp);
    for(const auto& i : catalyst) *(begin++) = i;
}


Unfortunately, I have to create this dummy variable in order to instantiate a vector. I tried std::vector<decltype(*curr)>, but the type becomes FOO &, making a container of references.

Is there any way to avoid this dummy variable?
1
2
    typedef typename std::iterator_traits<InIter>::value_type val_t;
    std::vector<val_t> catalyst;
Ah, thanks!
Topic archived. No new replies allowed.