Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/benchmark
diff options
context:
space:
mode:
authorZXShady2025-04-27 20:55:56 +0200
committerChris Thrasher2025-04-27 21:14:04 -0600
commit4ff57aba42938478f8b626c0862409f6eb7548f0 (patch)
tree2dd1a2762545b826fe466e1f6090c2bf91ec441b /src/catch2/benchmark
parentdde822061330510d5c3360bf062beaec60ccef08 (diff)
downloadcatch3-4ff57aba42938478f8b626c0862409f6eb7548f0.tar.gz
Use variable templates
Diffstat (limited to 'src/catch2/benchmark')
-rw-r--r--src/catch2/benchmark/catch_benchmark.hpp2
-rw-r--r--src/catch2/benchmark/detail/catch_benchmark_function.hpp5
2 files changed, 3 insertions, 4 deletions
diff --git a/src/catch2/benchmark/catch_benchmark.hpp b/src/catch2/benchmark/catch_benchmark.hpp
index d0f88cfc..eb688e7d 100644
--- a/src/catch2/benchmark/catch_benchmark.hpp
+++ b/src/catch2/benchmark/catch_benchmark.hpp
@@ -97,7 +97,7 @@ namespace Catch {
}
// sets lambda to be used in fun *and* executes benchmark!
- template <typename Fun, std::enable_if_t<!Detail::is_related<Fun, Benchmark>::value, int> = 0>
+ template <typename Fun, std::enable_if_t<!Detail::is_related_v<Fun, Benchmark>, int> = 0>
Benchmark & operator=(Fun func) {
auto const* cfg = getCurrentContext().getConfig();
if (!cfg->skipBenchmarks()) {
diff --git a/src/catch2/benchmark/detail/catch_benchmark_function.hpp b/src/catch2/benchmark/detail/catch_benchmark_function.hpp
index a03cb112..90b07b76 100644
--- a/src/catch2/benchmark/detail/catch_benchmark_function.hpp
+++ b/src/catch2/benchmark/detail/catch_benchmark_function.hpp
@@ -21,8 +21,7 @@ namespace Catch {
namespace Benchmark {
namespace Detail {
template <typename T, typename U>
- struct is_related
- : std::is_same<std::decay_t<T>, std::decay_t<U>> {};
+ static constexpr bool is_related_v = std::is_same<std::decay_t<T>, std::decay_t<U>>::value;
/// We need to reinvent std::function because every piece of code that might add overhead
/// in a measurement context needs to have consistent performance characteristics so that we
@@ -63,7 +62,7 @@ namespace Catch {
BenchmarkFunction();
template <typename Fun,
- std::enable_if_t<!is_related<Fun, BenchmarkFunction>::value, int> = 0>
+ std::enable_if_t<!is_related_v<Fun, BenchmarkFunction>, int> = 0>
BenchmarkFunction(Fun&& fun)
: f(new model<std::decay_t<Fun>>(CATCH_FORWARD(fun))) {}