diff --git a/nvbench/benchmark_base.cuh b/nvbench/benchmark_base.cuh index 7a1f594..2261b31 100644 --- a/nvbench/benchmark_base.cuh +++ b/nvbench/benchmark_base.cuh @@ -23,7 +23,7 @@ #include #include -#include // reference_wrapper +#include // reference_wrapper, ref #include #include #include @@ -153,9 +153,14 @@ struct benchmark_base void run() { this->do_run(); } - void set_printer(optional_ref printer) + void set_printer(nvbench::printer_base& printer) { - m_printer = printer; + m_printer = std::ref(printer); + } + + void clear_printer() + { + m_printer = std::nullopt; } [[nodiscard]] optional_ref get_printer() const diff --git a/nvbench/main.cuh b/nvbench/main.cuh index e5a624a..83a8672 100644 --- a/nvbench/main.cuh +++ b/nvbench/main.cuh @@ -24,9 +24,7 @@ #include #include -#include // std::ref #include -#include // std::nullopt #define NVBENCH_MAIN \ int main(int argc, char const *const *argv) \ @@ -59,9 +57,9 @@ auto &benchmarks = parser.get_benchmarks(); \ for (auto &bench_ptr : benchmarks) \ { \ - bench_ptr->set_printer(std::ref(printer)); \ + bench_ptr->set_printer(printer); \ bench_ptr->run(); \ - bench_ptr->set_printer(std::nullopt); \ + bench_ptr->clear_printer(); \ } \ printer.print_log_epilogue(); \ printer.print_benchmark_results(benchmarks); \