I'm writing some unit tests where the method tested should return a vector of objects. The method does not guarantee the order of the objects in the returned vector.
As part of the unit tests I have created a vector with the correct objects. I then need to check that the vector returned by the method contains the same objects as the vector with the correct objects.
I'm thinking that std::is_permutation can help here:
That's what the function is for. Alternatively, you could sort both vectors according to the same total order, and it should yield two identical vectors.
By default, is_permutation uses the == operator between two thing objects to determine equality. So just make sure you have that defined in a sane way (a == b should always be the same as b == a). Other than that, yeah it should work -- if you're having a specific issue, say what it is and we can help.