about summary refs log tree commit diff
path: root/absl/memory
diff options
context:
space:
mode:
Diffstat (limited to 'absl/memory')
-rw-r--r--absl/memory/memory.h4
-rw-r--r--absl/memory/memory_test.cc10
2 files changed, 14 insertions, 0 deletions
diff --git a/absl/memory/memory.h b/absl/memory/memory.h
index 959091388243..15cd85f4e1ed 100644
--- a/absl/memory/memory.h
+++ b/absl/memory/memory.h
@@ -81,6 +81,9 @@ struct MakeUniqueResult<T[N]> {
 
 }  // namespace memory_internal
 
+#if __cplusplus >= 201402L || defined(_MSC_VER)
+using std::make_unique;
+#else
 // -----------------------------------------------------------------------------
 // Function Template: make_unique<T>()
 // -----------------------------------------------------------------------------
@@ -164,6 +167,7 @@ typename memory_internal::MakeUniqueResult<T>::array make_unique(size_t n) {
 template <typename T, typename... Args>
 typename memory_internal::MakeUniqueResult<T>::invalid make_unique(
     Args&&... /* args */) = delete;
+#endif
 
 // -----------------------------------------------------------------------------
 // Function Template: RawPtr()
diff --git a/absl/memory/memory_test.cc b/absl/memory/memory_test.cc
index 8a5f5522a089..7d047ca0c726 100644
--- a/absl/memory/memory_test.cc
+++ b/absl/memory/memory_test.cc
@@ -138,6 +138,16 @@ TEST(Make_UniqueTest, Array) {
   EXPECT_THAT(ArrayWatch::allocs(), ElementsAre(5 * sizeof(ArrayWatch)));
 }
 
+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) {}
+  };
+  using absl::make_unique;
+  make_unique<TakesStdType>(std::vector<int>());
+}
+
 #if 0
 // TODO(billydonahue): Make a proper NC test.
 // These tests shouldn't compile.