Let's say I have a set of vector, where Pair is defined as follows:
struct Pair
{
int A;
int B;
}
std::vector<Pair> a = { {1,2}, {4,8}, {5,1}, {10,3} };
std::vector<Pair> b = { {1,2}, {4,9}, {5,1}, {10,3} };
std::vector<Pair> c = { {1,3}, {4,10}, {5,1}, {10,4} };
I want to create a new vector, in such a way that only elements which are common to all input vectors are input into the new vector as follows:
std::vector<Pair> abc = { {5,1} }; // {5,1} is only common value.
I have seen many questions asking for how to remove duplicates, but I wish to retain only duplicates.
I asked a similar question, but neglected to mention the non-sortable Pair type, which changes the problem.
Is there an existing efficient STL algorithm or construct that will do this for me, or do I need to write my own?