From 1ccb808a186d4dd8ac817170a80ce62301a11125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Lie=CC=81tar?= Date: Fri, 10 Apr 2020 12:36:36 +0200 Subject: [PATCH] Fix clang-tidy warning and CR comments. --- src/ds/helpers.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ds/helpers.h b/src/ds/helpers.h index 979c4b6..00159f8 100644 --- a/src/ds/helpers.h +++ b/src/ds/helpers.h @@ -108,7 +108,7 @@ namespace snmalloc * allocation. This is useful in the allocator code paths, where we can't * safely use std::function. * - * Inspired off the C++ proposal: + * Inspired by the C++ proposal: * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0792r2.html */ template @@ -116,12 +116,17 @@ namespace snmalloc template struct function_ref { - template - function_ref(Fn&& fn) + // The enable_if is used to stop this constructor from shadowing the default + // copy / move constructors. + template< + typename Fn, + typename = std::enable_if_t< + !std::is_same_v, function_ref>> function_ref(Fn&& fn) { data_ = static_cast(&fn); fn_ = execute; } + R operator()(Args... args) const { return fn_(data_, args...);