summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Soffer <asoffer@google.com>2020-01-02 21:49:07 (GMT)
committerAndy Soffer <asoffer@google.com>2020-01-02 21:49:07 (GMT)
commitfbe34cecf4ff34e0bed76aefb2b4d31f7b1f6819 (patch)
tree32657cef25abba46ad27500f6070f5d64b11a717
parenta13a0626188b4e7d22d63a4c9fcfe9f441c81e4a (diff)
parentbf31ed376ab1ae181dfa2bb0383f7710229b0d14 (diff)
downloadgoogletest-fbe34cecf4ff34e0bed76aefb2b4d31f7b1f6819.zip
googletest-fbe34cecf4ff34e0bed76aefb2b4d31f7b1f6819.tar.gz
googletest-fbe34cecf4ff34e0bed76aefb2b4d31f7b1f6819.tar.bz2
Merge pull request #2639 from trzecieu:trzeci/move_ctor_assign
PiperOrigin-RevId: 286896167
-rw-r--r--googletest/include/gtest/internal/gtest-internal.h7
-rw-r--r--googletest/include/gtest/internal/gtest-port.h19
2 files changed, 21 insertions, 5 deletions
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index 57ebbda..41c94f4 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -1405,12 +1405,15 @@ constexpr bool InstantiateTypedTestCase_P_IsDeprecated() { return true; }
: public parent_class { \
public: \
GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \
+ ~GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() = default; \
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \
+ test_name)); \
+ GTEST_DISALLOW_MOVE_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \
+ test_name)); \
\
private: \
void TestBody() override; \
static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_; \
- GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \
- test_name)); \
}; \
\
::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_suite_name, \
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index fcaac0b..0543da5 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -190,8 +190,10 @@
// GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.
// GTEST_ATTRIBUTE_UNUSED_ - declares that a class' instances or a
// variable don't have to be used.
-// GTEST_DISALLOW_ASSIGN_ - disables operator=.
+// GTEST_DISALLOW_ASSIGN_ - disables copy operator=.
// GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.
+// GTEST_DISALLOW_MOVE_ASSIGN_ - disables move operator=.
+// GTEST_DISALLOW_MOVE_AND_ASSIGN_ - disables move ctor and operator=.
// GTEST_MUST_USE_RESULT_ - declares that a function's result must be used.
// GTEST_INTENTIONAL_CONST_COND_PUSH_ - start code section where MSVC C4127 is
// suppressed (constant conditional).
@@ -666,10 +668,10 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#endif
-// A macro to disallow operator=
+// A macro to disallow copy operator=
// This should be used in the private: declarations for a class.
#define GTEST_DISALLOW_ASSIGN_(type) \
- void operator=(type const &) = delete
+ type& operator=(type const &) = delete
// A macro to disallow copy constructor and operator=
// This should be used in the private: declarations for a class.
@@ -677,6 +679,17 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
type(type const &) = delete; \
GTEST_DISALLOW_ASSIGN_(type)
+// A macro to disallow move operator=
+// This should be used in the private: declarations for a class.
+#define GTEST_DISALLOW_MOVE_ASSIGN_(type) \
+ type& operator=(type &&) noexcept = delete
+
+// A macro to disallow move constructor and operator=
+// 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)
+
// Tell the compiler to warn about unused return values for functions declared
// with this macro. The macro should be used on function declarations
// following the argument list: