mardi 4 avril 2017

std::list::merge() fails for lists containing objects

I have following situation:

#include <list>

struct Example
{
    double p1;
    double p2;
};

void f()
{
    std::list<Example> list1;
    std::list<Example> list2;
    list1.merge(list2);
}

During build I get errors:

C2672 'operator __surrogate_func': no matching overloaded function found

C2893 Failed to specialize function template 'unknown-type std::less<void>::operator() (_Ty1 &&,_Ty2&&) const'

If I comment the last line of code, the build is successful. I find it hard to believe that lists that contain objects cannot be merged, so: what am I missing?

PS. I use Visual Studio Community 2015

Aucun commentaire:

Enregistrer un commentaire