Q:

STL Container move selected elements

How to select elements with certain value from STL container and move them at the end of that container?

A:

You could try using std::partition with a predicate that returns true for elements not equal to the target value. If you need to to preserve the relative order of the elements there is also std::stable_partition.

A:

Considering you made a comment about wanting to use std::vector, I'd suggest using std::partition or std::stable_partition, i.e.:
#include <algorithm>
#include <functional>
#include <iostream>
#include <iterator>
#include <vector>

int main()
{
    int init_values[] = {1, 1, 7, 3, 19, 5, 5, 4, 5, 2, 5, 8, 9, 10, 5, 1};
    std::vector<int> values(
        init_values,
        init_values + sizeof(init_values) / sizeof(int)
    );

    std::stable_partition(
        values.begin(), values.end(),
        std::bind1st(std::not_equal_to<int>(), 5)
    );

    std::copy(values.begin(), values.end(), std::ostream_iterator<int>(std::cout, ", "));
    std::cout << "\n";

    return 0;
}

This code will move all elements of the vector that are equal to 5 to the end of the vector, keeping the relative order of the remaining elements in tact.

