From f31c2c6f380331ddc862e37c7dea0bcf440b29dc Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Mon, 13 May 2024 18:23:14 +0000 Subject: [PATCH] Restore `bool T::ParseFrom(const char*, size_t)` support for MSVC. IIRC, it was problematic for MSVC 2017 and/or MSVC 2019, but https://github.com/google/oss-policies-info/commit/dca3ce04cd812e03c71107a7fdea419acbd6432c raised the support baseline to MSVC 2022, so let's try it... Change-Id: Id00483381c1f6c499a2da0c2d40d235c95dedfaa Reviewed-on: https://code-review.googlesource.com/c/re2/+/63050 Reviewed-by: Alex Chernyakhovsky Reviewed-by: Paul Wankadia --- re2/re2.h | 6 ------ re2/testing/re2_arg_test.cc | 2 -- 2 files changed, 8 deletions(-) diff --git a/re2/re2.h b/re2/re2.h index 7ea44e044..13bf39fbe 100644 --- a/re2/re2.h +++ b/re2/re2.h @@ -890,14 +890,12 @@ class RE2::Arg { re2_internal::Parse4ary::value, int>::type; -#if !defined(_MSC_VER) template using CanParseFrom = typename std::enable_if< std::is_member_function_pointer< decltype(static_cast( &T::ParseFrom))>::value, int>::type; -#endif public: Arg() : Arg(nullptr) {} @@ -909,10 +907,8 @@ class RE2::Arg { template = 0> Arg(T* ptr) : arg_(ptr), parser_(DoParse4ary) {} -#if !defined(_MSC_VER) template = 0> Arg(T* ptr) : arg_(ptr), parser_(DoParseFrom) {} -#endif typedef bool (*Parser)(const char* str, size_t n, void* dest); @@ -938,13 +934,11 @@ class RE2::Arg { return re2_internal::Parse(str, n, reinterpret_cast(dest), 10); } -#if !defined(_MSC_VER) template static bool DoParseFrom(const char* str, size_t n, void* dest) { if (dest == NULL) return true; return reinterpret_cast(dest)->ParseFrom(str, n); } -#endif void* arg_; Parser parser_; diff --git a/re2/testing/re2_arg_test.cc b/re2/testing/re2_arg_test.cc index 4b00be358..78d4aee43 100644 --- a/re2/testing/re2_arg_test.cc +++ b/re2/testing/re2_arg_test.cc @@ -135,7 +135,6 @@ TEST(RE2ArgTest, Uint64Test) { } TEST(RE2ArgTest, ParseFromTest) { -#if !defined(_MSC_VER) struct { bool ParseFrom(const char* str, size_t n) { LOG(INFO) << "str = " << str << ", n = " << n; @@ -155,7 +154,6 @@ TEST(RE2ArgTest, ParseFromTest) { } obj2; RE2::Arg arg2(&obj2); EXPECT_FALSE(arg2.Parse("two", 3)); -#endif } TEST(RE2ArgTest, OptionalDoubleTest) {