mardi 28 février 2017

How to compare a container and a initializer-list to see if they are equal?

For example

template<class Container, class List>
bool isEqual(Container const& c, List const& l)
{
    return c == Container(l); // Error!!
}

And check by

std::vector<int> v;
bool b = isEqual(v, {1, 2, 3});

But error in my code. No conversion from list to container. How to fix the bug?

Aucun commentaire:

Enregistrer un commentaire