| 243 | |
| 244 | template<class Container> |
| 245 | static void benchPopFront() |
| 246 | { |
| 247 | const auto toElementType = [](int i) { |
| 248 | using ElementType = typename Container::value_type; |
| 249 | const auto str = QString::number(i); |
| 250 | if constexpr (std::is_integral_v<ElementType>) { |
| 251 | return IndexedString::indexForString(str); |
| 252 | } else { |
| 253 | return ElementType{str}; |
| 254 | } |
| 255 | }; |
| 256 | |
| 257 | Container container; |
| 258 | for (int i = 0; i < 10000; ++i) { |
| 259 | container.push_back(toElementType(i)); |
| 260 | } |
| 261 | // deliberately do a worst-case remove-from-front here |
| 262 | // we want to see how this performs without any noexcept move operators |
| 263 | QBENCHMARK_ONCE { |
| 264 | while (!container.empty()) { |
| 265 | container.erase(container.begin()); |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | void BenchIndexedString::bench_string_vector() |
| 271 | { |