All combinations of two pairs of elements of an array
Unused variables
We never use targetVector, so we can omit its definition.
Reduce scope
We can move pair1 and pair2 inside of the do loop.
Don't cast to signed
This looks like a misguided attempt to appease a compiler warning:
    for (int i = 0; i &lt; (int)index_pair.size(); i++) {

Whilst it's good that you have enabled a good set of warnings, the better response would be to change the type of i to match (especially as we intend to use it as an indexer):
    for (std::size_t i = 0u;  i &lt; index_pair.size();  ++i) {

We can also simplify the if chain if we use a small array for pair:
    std::size_t pair[3] = {};

    for (std::size_t i = 0u;  i &lt; index_pair.size();  ++i)
        pair[index_pair[i]] += 1u &lt;&lt; (i+1);

    if (pair[1] &gt; pair[2]) {

We could use range-based for instead:
    std::size_t n = 0;
    for (auto i: index_pair)
        pair[i] += 1u &lt;&lt; ++n;

It's not obvious whether this is better than the index loop, but you might prefer it.
A typo
You appear to have misspelt std::prev_permutation in the while condition.

Modified code
Without changing the algorithm, I have simplified to just
#include &lt;algorithm&gt;
#include &lt;iostream&gt;
#include &lt;vector&gt;

int main()
{
    std::vector&lt;int&gt; index_pair = { 2, 2, 1, 1, 0 };

    do {
        std::size_t pair[3] = {};

        for (std::size_t i = 0u;  i &lt; index_pair.size();  ++i)
            pair[index_pair[i]] += 1u &lt;&lt; (i+1);

        if (pair[1] &gt; pair[2]) {
            for (auto index: index_pair) {
                std::cout &lt;&lt; index;
            }
            std::cout &lt;&lt; &quot;\n&quot;;
        }
    } while (std::prev_permutation(index_pair.begin(), index_pair.end()));
}