Copy and bit-invert ints in an std::vector I want a second copy of an std::vector in which all elements are inverted, e.g. 0x01 in the first vector should be 0xFE in the second. 

Is this a good solution?

std::vector&lt;uint8_t&gt; first_list = {0x01, 0x10, 0x32, 0x1A };
std::vector&lt;uint8_t&gt; second_list = first_list;
for(std::vector&lt;uint8_t&gt;::iterator it = second_list.begin(); it != second_list.end(); ++it)
    *it = ~*it;


The for loop sticks out to me as unnecessarily verbose.
You can utilize std::transform here (I'll assume C++11 for the lambda):

int main()
{
    std::vector&lt;uint8_t&gt; first_list = {0x01, 0x10, 0x32, 0x1A};
    std::vector&lt;uint8_t&gt; second; 
    std::transform(first_list.begin(), first_list.end(), std::back_inserter(second),
                   [](uint8_t u) { return ~u; });
}


You also don't need to make a copy of the first vector to do this; better to simply use push_back (or back_inserter here, since we're working with iterators).