diff options
author | Arthur O'Dwyer <arthur.j.odwyer@gmail.com> | 2020-04-16 19:52:17 (GMT) |
---|---|---|
committer | Arthur O'Dwyer <arthur.j.odwyer@gmail.com> | 2020-04-24 02:22:07 (GMT) |
commit | 766ac2e1a413e87d42d67e3286c70f0af4853679 (patch) | |
tree | c9768ae1a96fee8146c0327f90db0ce0be060b8d /googletest/include/gtest/internal/gtest-port.h | |
parent | 4f002f1e236c1a0e7bdb096cd845f1a9c6c129c6 (diff) | |
download | googletest-766ac2e1a413e87d42d67e3286c70f0af4853679.zip googletest-766ac2e1a413e87d42d67e3286c70f0af4853679.tar.gz googletest-766ac2e1a413e87d42d67e3286c70f0af4853679.tar.bz2 |
Remove all uses of GTEST_DISALLOW_{MOVE_,}ASSIGN_.
None of these are strictly needed for correctness.
A large number of them (maybe all of them?) trigger `-Wdeprecated`
warnings on Clang trunk as soon as you try to use the implicitly
defaulted (but deprecated) copy constructor of a class that has
deleted its copy assignment operator.
By declaring a deleted copy assignment operator, the old code
also caused the move constructor and move assignment operator
to be non-declared. This means that the old code never got move
semantics -- "move-construction" would simply call the defaulted
(but deprecated) copy constructor instead. With the new code,
"move-construction" calls the defaulted move constructor, which
I believe is what we want to happen. So this is a runtime
performance optimization.
Unfortunately we can't yet physically remove the definitions
of these macros from gtest-port.h, because they are being used
by other code internally at Google (according to zhangxy988).
But no new uses should be added going forward.
Diffstat (limited to 'googletest/include/gtest/internal/gtest-port.h')
-rw-r--r-- | googletest/include/gtest/internal/gtest-port.h | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 21fcf82..44307a1 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -682,7 +682,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // This should be used in the private: declarations for a class. #define GTEST_DISALLOW_COPY_AND_ASSIGN_(type) \ type(type const &) = delete; \ - GTEST_DISALLOW_ASSIGN_(type) + type& operator=(type const &) = delete // A macro to disallow move operator= // This should be used in the private: declarations for a class. @@ -693,7 +693,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // This should be used in the private: declarations for a class. #define GTEST_DISALLOW_MOVE_AND_ASSIGN_(type) \ type(type &&) noexcept = delete; \ - GTEST_DISALLOW_MOVE_ASSIGN_(type) + type& operator=(type &&) noexcept = delete // Tell the compiler to warn about unused return values for functions declared // with this macro. The macro should be used on function declarations @@ -920,8 +920,6 @@ class GTEST_API_ RE { const char* full_pattern_; // For FullMatch(); # endif - - GTEST_DISALLOW_ASSIGN_(RE); }; #endif // GTEST_USES_PCRE |