[libcxx-commits] [libcxx] [libc++] Add benchmarks for std::replace_copy and std::replace_copy_if (PR #207070)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 14 05:50:45 PDT 2026


================
@@ -0,0 +1,129 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+#include <algorithm>
+#include <cstddef>
+#include <deque>
+#include <iterator>
+#include <list>
+#include <string>
+#include <vector>
+
+#include "benchmark/benchmark.h"
+#include "../../GenerateInput.h"
+
+int main(int argc, char** argv) {
+  auto std_replace_copy = [](auto first, auto last, auto out, auto const& old_value, auto const& new_value) {
+    return std::replace_copy(first, last, out, old_value, new_value);
+  };
+  auto std_replace_copy_if = [](auto first, auto last, auto out, auto const& old_value, auto const& new_value) {
+    return std::replace_copy_if(
+        first,
+        last,
+        out,
+        [&](auto element) {
+          benchmark::DoNotOptimize(element);
----------------
ldionne wrote:

Ack, yes I forgot to update the PR after the other ones. Doing

https://github.com/llvm/llvm-project/pull/207070


More information about the libcxx-commits mailing list