Is there a common idiom for doing something twice, as in the following situation?
for ( int i = 0; i < num_pairs; i++ ) {
cards.push_back( Card(i) );
cards.push_back( Card(i) );
}
I have a feeling that there's a clearer way than introducing a new loop variable counting from 0 to 1, especially since it isn't used except for counting.
for ( int i = 0; i < num_pairs; i++ )
for ( int j = 0; j < 2; j++ )
cards.push_back( Card(i) );
(Card
is just some class I made up and not relevant to the question.)