jeudi 29 juillet 2021

How to identify template parameters in Container1

I have a code as below. It fails in compilation, saying Container2 is ambiguous. How can I resolve it?

#include <vector>    
using namespace std;

template<class T, template<class...> class Container2, template<class...> class Container1>    
vector<T> catenate(Container1<Container2<T>> const& tss)
{
    vector<T> res;
    for (auto& ts : tss)
        res.insert(res.end(), ts.begin(), ts.end());
    return res;
}

int main()
{
    vector<vector<int>> vv;
    catenate(vv);
}

Aucun commentaire:

Enregistrer un commentaire