void operator()(Cont& c, long count) {
     long cnt = count * 10;
     if (cnt > c.size()) {
         cout << "RemoveBack: not enough elements"
              << endl;
         return;
     }
     for (long i = 0; i < cnt; i++)
         c.pop_back();
 }
Example #2
0
void updateContainer(Cont<T, Alloc>& cont) {
   // flip a coin to determine using emplace_back() with 80% of likelihood, or pop_back() with 20% of likelihood.
   static std::bernoulli_distribution dist(.8);
   if (cont.empty() || dist(S1::s_gen)) {
      cont.emplace_back();
   } else {
      cont.pop_back();
   }
   // and with 20% likelihood mutating 1st and last elem's std::string field
   if (!cont.empty() && !dist(S1::s_gen)) {
      cont.front().m_str.append("- foo");
      cont.back().m_str.append("- bar");
   }
}