about summary refs log tree commit diff
path: root/third_party/abseil_cpp/absl/memory
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-11-21T13·43+0100
committerVincent Ambo <mail@tazj.in>2020-11-21T14·48+0100
commit082c006c04343a78d87b6c6ab3608c25d6213c3f (patch)
tree16e6f04f8d1d1d2d67e8e917d5e7bb48c1b60375 /third_party/abseil_cpp/absl/memory
parentcc27324d0226953943f408ce3c69ad7d648e005e (diff)
merge(3p/absl): subtree merge of Abseil up to e19260f r/1889
... notably, this includes Abseil's own StatusOr type, which
conflicted with our implementation (that was taken from TensorFlow).

Change-Id: Ie7d6764b64055caaeb8dc7b6b9d066291e6b538f
Diffstat (limited to 'third_party/abseil_cpp/absl/memory')
-rw-r--r--third_party/abseil_cpp/absl/memory/BUILD.bazel2
-rw-r--r--third_party/abseil_cpp/absl/memory/memory.h4
-rw-r--r--third_party/abseil_cpp/absl/memory/memory_test.cc38
3 files changed, 23 insertions, 21 deletions
diff --git a/third_party/abseil_cpp/absl/memory/BUILD.bazel b/third_party/abseil_cpp/absl/memory/BUILD.bazel
index 2ba9d7cb98ae..d2824a05adda 100644
--- a/third_party/abseil_cpp/absl/memory/BUILD.bazel
+++ b/third_party/abseil_cpp/absl/memory/BUILD.bazel
@@ -24,7 +24,7 @@ load(
 
 package(default_visibility = ["//visibility:public"])
 
-licenses(["notice"])  # Apache 2.0
+licenses(["notice"])
 
 cc_library(
     name = "memory",
diff --git a/third_party/abseil_cpp/absl/memory/memory.h b/third_party/abseil_cpp/absl/memory/memory.h
index 513f7103a00c..2b5ff623d430 100644
--- a/third_party/abseil_cpp/absl/memory/memory.h
+++ b/third_party/abseil_cpp/absl/memory/memory.h
@@ -420,6 +420,9 @@ struct pointer_traits<T*> {
 //
 // A C++11 compatible implementation of C++17's std::allocator_traits.
 //
+#if __cplusplus >= 201703L
+using std::allocator_traits;
+#else  // __cplusplus >= 201703L
 template <typename Alloc>
 struct allocator_traits {
   using allocator_type = Alloc;
@@ -609,6 +612,7 @@ struct allocator_traits {
     return a;
   }
 };
+#endif  // __cplusplus >= 201703L
 
 namespace memory_internal {
 
diff --git a/third_party/abseil_cpp/absl/memory/memory_test.cc b/third_party/abseil_cpp/absl/memory/memory_test.cc
index c47820e54ab0..1990c7ba4728 100644
--- a/third_party/abseil_cpp/absl/memory/memory_test.cc
+++ b/third_party/abseil_cpp/absl/memory/memory_test.cc
@@ -17,6 +17,7 @@
 #include "absl/memory/memory.h"
 
 #include <sys/types.h>
+
 #include <cstddef>
 #include <memory>
 #include <string>
@@ -36,10 +37,10 @@ using ::testing::Return;
 // been called, via the instance_count variable.
 class DestructorVerifier {
  public:
-  DestructorVerifier() { ++instance_count_;  }
+  DestructorVerifier() { ++instance_count_; }
   DestructorVerifier(const DestructorVerifier&) = delete;
   DestructorVerifier& operator=(const DestructorVerifier&) = delete;
-  ~DestructorVerifier() {  --instance_count_; }
+  ~DestructorVerifier() { --instance_count_; }
 
   // The number of instances of this class currently active.
   static int instance_count() { return instance_count_; }
@@ -156,9 +157,7 @@ struct ArrayWatch {
     allocs().push_back(n);
     return ::operator new[](n);
   }
-  void operator delete[](void* p) {
-    return ::operator delete[](p);
-  }
+  void operator delete[](void* p) { return ::operator delete[](p); }
   static std::vector<size_t>& allocs() {
     static auto& v = *new std::vector<size_t>;
     return v;
@@ -171,8 +170,7 @@ TEST(Make_UniqueTest, Array) {
   ArrayWatch::allocs().clear();
 
   auto p = absl::make_unique<ArrayWatch[]>(5);
-  static_assert(std::is_same<decltype(p),
-                             std::unique_ptr<ArrayWatch[]>>::value,
+  static_assert(std::is_same<decltype(p), std::unique_ptr<ArrayWatch[]>>::value,
                 "unexpected return type");
   EXPECT_THAT(ArrayWatch::allocs(), ElementsAre(5 * sizeof(ArrayWatch)));
 }
@@ -181,7 +179,7 @@ TEST(Make_UniqueTest, NotAmbiguousWithStdMakeUnique) {
   // Ensure that absl::make_unique is not ambiguous with std::make_unique.
   // In C++14 mode, the below call to make_unique has both types as candidates.
   struct TakesStdType {
-    explicit TakesStdType(const std::vector<int> &vec) {}
+    explicit TakesStdType(const std::vector<int>& vec) {}
   };
   using absl::make_unique;
   (void)make_unique<TakesStdType>(std::vector<int>());
@@ -541,8 +539,8 @@ struct MinimalMockAllocator {
   MinimalMockAllocator(const MinimalMockAllocator& other)
       : value(other.value) {}
   using value_type = TestValue;
-  MOCK_METHOD1(allocate, value_type*(size_t));
-  MOCK_METHOD2(deallocate, void(value_type*, size_t));
+  MOCK_METHOD(value_type*, allocate, (size_t));
+  MOCK_METHOD(void, deallocate, (value_type*, size_t));
 
   int value;
 };
@@ -557,7 +555,7 @@ TEST(AllocatorTraits, FunctionsMinimal) {
   EXPECT_CALL(mock, deallocate(&x, 7));
 
   EXPECT_EQ(&x, Traits::allocate(mock, 7));
-  Traits::allocate(mock, 7, static_cast<const void*>(&hint));
+  static_cast<void>(Traits::allocate(mock, 7, static_cast<const void*>(&hint)));
   EXPECT_EQ(&x, Traits::allocate(mock, 7, static_cast<const void*>(&hint)));
   Traits::deallocate(mock, &x, 7);
 
@@ -579,13 +577,14 @@ struct FullMockAllocator {
   explicit FullMockAllocator(int value) : value(value) {}
   FullMockAllocator(const FullMockAllocator& other) : value(other.value) {}
   using value_type = TestValue;
-  MOCK_METHOD1(allocate, value_type*(size_t));
-  MOCK_METHOD2(allocate, value_type*(size_t, const void*));
-  MOCK_METHOD2(construct, void(value_type*, int*));
-  MOCK_METHOD1(destroy, void(value_type*));
-  MOCK_CONST_METHOD0(max_size, size_t());
-  MOCK_CONST_METHOD0(select_on_container_copy_construction,
-                     FullMockAllocator());
+  MOCK_METHOD(value_type*, allocate, (size_t));
+  MOCK_METHOD(value_type*, allocate, (size_t, const void*));
+  MOCK_METHOD(void, construct, (value_type*, int*));
+  MOCK_METHOD(void, destroy, (value_type*));
+  MOCK_METHOD(size_t, max_size, (),
+              (const));
+  MOCK_METHOD(FullMockAllocator, select_on_container_copy_construction, (),
+              (const));
 
   int value;
 };
@@ -642,8 +641,7 @@ TEST(AllocatorNoThrowTest, CustomAllocator) {
   struct CanThrowAllocator {
     using is_nothrow = std::false_type;
   };
-  struct UnspecifiedAllocator {
-  };
+  struct UnspecifiedAllocator {};
   EXPECT_TRUE(absl::allocator_is_nothrow<NoThrowAllocator>::value);
   EXPECT_FALSE(absl::allocator_is_nothrow<CanThrowAllocator>::value);
   EXPECT_FALSE(absl::allocator_is_nothrow<UnspecifiedAllocator>::value);