https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101923
--- Comment #1 from Petar Ivanov <dartdart26 at gmail dot com> ---
Benchmark code (using Google Benchmark):
#include <benchmark/benchmark.h>
#include <functional>
#include <utility>
struct Car {};
static void copy(benchmark::State& state) {
for (auto _ : state) {
const auto f = std::function<void(const Car&)>{};
const auto copied = f;
benchmark::DoNotOptimize(copied);
}
}
static void move(benchmark::State& state) {
for (auto _ : state) {
auto f = std::function<void(const Car&)>{};
const auto moved = std::move(f);
benchmark::DoNotOptimize(moved);
}
}
BENCHMARK(copy);
BENCHMARK(move);
BENCHMARK_MAIN();