aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsskvor <sskvor@yandex-team.com>2022-10-07 12:53:10 +0300
committersskvor <sskvor@yandex-team.com>2022-10-07 12:53:10 +0300
commitd10b241085e3d8ea303601bf61d35b2b11ad8146 (patch)
treee00c18a9bc882ca754435d02f90797ed0ccd7d43
parent67090ca0f04c5c866c38abf31b98de061025c8d4 (diff)
downloadydb-d10b241085e3d8ea303601bf61d35b2b11ad8146.tar.gz
[util] Fix TFunctionRef under MSVC
-rw-r--r--util/CMakeLists.darwin.txt4
-rw-r--r--util/CMakeLists.linux.txt4
-rw-r--r--util/generic/function_ref.h21
3 files changed, 23 insertions, 6 deletions
diff --git a/util/CMakeLists.darwin.txt b/util/CMakeLists.darwin.txt
index fad213978ee..14ee4fefbbc 100644
--- a/util/CMakeLists.darwin.txt
+++ b/util/CMakeLists.darwin.txt
@@ -26,7 +26,6 @@ target_sources(yutil PRIVATE
${CMAKE_SOURCE_DIR}/util/digest/city.cpp
${CMAKE_SOURCE_DIR}/util/random/random.cpp
${CMAKE_SOURCE_DIR}/util/string/cast.cpp
- ${CMAKE_SOURCE_DIR}/util/generic/function_ref.cpp
)
target_joined_source(yutil
all_datetime.cpp
@@ -63,7 +62,6 @@ target_joined_source(yutil
)
target_joined_source(yutil
all_generic.cpp
- ${CMAKE_SOURCE_DIR}/util/generic/scope.cpp
${CMAKE_SOURCE_DIR}/util/generic/adaptor.cpp
${CMAKE_SOURCE_DIR}/util/generic/algorithm.cpp
${CMAKE_SOURCE_DIR}/util/generic/array_ref.cpp
@@ -78,6 +76,7 @@ target_joined_source(yutil
${CMAKE_SOURCE_DIR}/util/generic/fastqueue.cpp
${CMAKE_SOURCE_DIR}/util/generic/flags.cpp
${CMAKE_SOURCE_DIR}/util/generic/function.cpp
+ ${CMAKE_SOURCE_DIR}/util/generic/function_ref.cpp
${CMAKE_SOURCE_DIR}/util/generic/fwd.cpp
${CMAKE_SOURCE_DIR}/util/generic/guid.cpp
${CMAKE_SOURCE_DIR}/util/generic/hash.cpp
@@ -102,6 +101,7 @@ target_joined_source(yutil
${CMAKE_SOURCE_DIR}/util/generic/ptr.cpp
${CMAKE_SOURCE_DIR}/util/generic/queue.cpp
${CMAKE_SOURCE_DIR}/util/generic/refcount.cpp
+ ${CMAKE_SOURCE_DIR}/util/generic/scope.cpp
${CMAKE_SOURCE_DIR}/util/generic/serialized_enum.cpp
${CMAKE_SOURCE_DIR}/util/generic/set.cpp
${CMAKE_SOURCE_DIR}/util/generic/singleton.cpp
diff --git a/util/CMakeLists.linux.txt b/util/CMakeLists.linux.txt
index b21eed3b72e..7697d6f9c0b 100644
--- a/util/CMakeLists.linux.txt
+++ b/util/CMakeLists.linux.txt
@@ -26,7 +26,6 @@ target_sources(yutil PRIVATE
${CMAKE_SOURCE_DIR}/util/digest/city.cpp
${CMAKE_SOURCE_DIR}/util/random/random.cpp
${CMAKE_SOURCE_DIR}/util/string/cast.cpp
- ${CMAKE_SOURCE_DIR}/util/generic/function_ref.cpp
${CMAKE_SOURCE_DIR}/util/system/valgrind.cpp
${CMAKE_SOURCE_DIR}/util/system/mktemp_system.cpp
)
@@ -65,7 +64,6 @@ target_joined_source(yutil
)
target_joined_source(yutil
all_generic.cpp
- ${CMAKE_SOURCE_DIR}/util/generic/scope.cpp
${CMAKE_SOURCE_DIR}/util/generic/adaptor.cpp
${CMAKE_SOURCE_DIR}/util/generic/algorithm.cpp
${CMAKE_SOURCE_DIR}/util/generic/array_ref.cpp
@@ -80,6 +78,7 @@ target_joined_source(yutil
${CMAKE_SOURCE_DIR}/util/generic/fastqueue.cpp
${CMAKE_SOURCE_DIR}/util/generic/flags.cpp
${CMAKE_SOURCE_DIR}/util/generic/function.cpp
+ ${CMAKE_SOURCE_DIR}/util/generic/function_ref.cpp
${CMAKE_SOURCE_DIR}/util/generic/fwd.cpp
${CMAKE_SOURCE_DIR}/util/generic/guid.cpp
${CMAKE_SOURCE_DIR}/util/generic/hash.cpp
@@ -104,6 +103,7 @@ target_joined_source(yutil
${CMAKE_SOURCE_DIR}/util/generic/ptr.cpp
${CMAKE_SOURCE_DIR}/util/generic/queue.cpp
${CMAKE_SOURCE_DIR}/util/generic/refcount.cpp
+ ${CMAKE_SOURCE_DIR}/util/generic/scope.cpp
${CMAKE_SOURCE_DIR}/util/generic/serialized_enum.cpp
${CMAKE_SOURCE_DIR}/util/generic/set.cpp
${CMAKE_SOURCE_DIR}/util/generic/singleton.cpp
diff --git a/util/generic/function_ref.h b/util/generic/function_ref.h
index c55de8694c9..814f0745bfd 100644
--- a/util/generic/function_ref.h
+++ b/util/generic/function_ref.h
@@ -5,11 +5,28 @@
#include <functional>
-template <typename Signature>
+namespace NPrivate {
+
+ template <typename Signature>
+ struct TIsNoexcept;
+
+ template <typename Ret, typename... Args>
+ struct TIsNoexcept<Ret(Args...)> {
+ static constexpr bool Value = false;
+ };
+
+ template <typename Ret, typename... Args>
+ struct TIsNoexcept<Ret(Args...) noexcept> {
+ static constexpr bool Value = true;
+ };
+
+} // namespace NPrivate
+
+template <typename Signature, bool IsNoexcept = NPrivate::TIsNoexcept<Signature>::Value>
class TFunctionRef;
template <typename Ret, typename... Args, bool IsNoexcept>
-class TFunctionRef<Ret(Args...) noexcept(IsNoexcept)> {
+class TFunctionRef<Ret(Args...) noexcept(IsNoexcept), IsNoexcept> {
public:
using TSignature = Ret(Args...) noexcept(IsNoexcept);