Container initialization in C++98

Viewed 1103

I have to construct an ordered container (which must be iterable) with the following rule:

If the condition is true, the container is {1,0}, else it's {0,1}

I have the following code, but I don't find it "elegant":

   vector<int> orderedSides;
   if (condition) 
   {
       orderedSides.push_back(1);
       orderedSides.push_back(0);
   }
   else            
   {
       orderedSides.push_back(0);
       orderedSides.push_back(1);
   }

Is there a better way to do this (from concision and performance point of view)?

6 Answers
Related