summaryrefslogtreecommitdiffstats
path: root/googletest/include/gtest/internal/gtest-port.h
diff options
context:
space:
mode:
authormisterg <misterg@google.com>2018-10-30 13:49:22 (GMT)
committerGennadiy Civil <misterg@google.com>2018-10-31 01:20:43 (GMT)
commite857f9cdd998136b9aad634272301f5b2d0476ea (patch)
treefb1ddc72b8448eba93fde494bdf12347ab52bc66 /googletest/include/gtest/internal/gtest-port.h
parente0d3c37051865bf2ec32de3be0a408a8f2a106ac (diff)
downloadgoogletest-e857f9cdd998136b9aad634272301f5b2d0476ea.zip
googletest-e857f9cdd998136b9aad634272301f5b2d0476ea.tar.gz
googletest-e857f9cdd998136b9aad634272301f5b2d0476ea.tar.bz2
Googletest export
Remove scoped_ptr replace with std::unique_ptr PiperOrigin-RevId: 219291284
Diffstat (limited to 'googletest/include/gtest/internal/gtest-port.h')
-rw-r--r--googletest/include/gtest/internal/gtest-port.h52
1 files changed, 5 insertions, 47 deletions
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 5e302ae..b618289 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -212,8 +212,6 @@
// IteratorTraits - partial implementation of std::iterator_traits, which
// is not available in libCstd when compiled with Sun C++.
//
-// Smart pointers:
-// scoped_ptr - as in TR2.
//
// Regular expressions:
// RE - a simple regular expression class using the POSIX
@@ -253,9 +251,11 @@
#include <ctype.h> // for isspace, etc
#include <stddef.h> // for ptrdiff_t
-#include <stdlib.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+#include <memory>
+
#ifndef _WIN32_WCE
# include <sys/types.h>
# include <sys/stat.h>
@@ -1010,48 +1010,6 @@ typedef ::std::wstring wstring;
// returns 'condition'.
GTEST_API_ bool IsTrue(bool condition);
-// Defines scoped_ptr.
-
-// This implementation of scoped_ptr is PARTIAL - it only contains
-// enough stuff to satisfy Google Test's need.
-template <typename T>
-class scoped_ptr {
- public:
- typedef T element_type;
-
- explicit scoped_ptr(T* p = nullptr) : ptr_(p) {}
- ~scoped_ptr() { reset(); }
-
- T& operator*() const { return *ptr_; }
- T* operator->() const { return ptr_; }
- T* get() const { return ptr_; }
-
- T* release() {
- T* const ptr = ptr_;
- ptr_ = nullptr;
- return ptr;
- }
-
- void reset(T* p = nullptr) {
- if (p != ptr_) {
- if (IsTrue(sizeof(T) > 0)) { // Makes sure T is a complete type.
- delete ptr_;
- }
- ptr_ = p;
- }
- }
-
- friend void swap(scoped_ptr& a, scoped_ptr& b) {
- using std::swap;
- swap(a.ptr_, b.ptr_);
- }
-
- private:
- T* ptr_;
-
- GTEST_DISALLOW_COPY_AND_ASSIGN_(scoped_ptr);
-};
-
// Defines RE.
#if GTEST_USES_PCRE
@@ -1845,7 +1803,7 @@ class ThreadLocal : public ThreadLocalBase {
GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory);
};
- scoped_ptr<ValueHolderFactory> default_factory_;
+ std::unique_ptr<ValueHolderFactory> default_factory_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);
};
@@ -2056,7 +2014,7 @@ class GTEST_API_ ThreadLocal {
// A key pthreads uses for looking up per-thread values.
const pthread_key_t key_;
- scoped_ptr<ValueHolderFactory> default_factory_;
+ std::unique_ptr<ValueHolderFactory> default_factory_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);
};