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"); } }