summaryrefslogtreecommitdiff
path: root/absl/memory
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2017-10-23 11:40:35 -0700
committerGravatar Jon Cohen <cohenjon@google.com>2017-10-23 15:26:40 -0400
commit5fcbe86e7ba65b6457d98764aa511c4f05c9435b (patch)
treeb2cea4280fa7c22dfe8313c2035499037a34179f /absl/memory
parent6cf9c731027f4d8aebe3c60df8e64317e6870870 (diff)
Changes imported from Abseil "staging" branch:
- 989557e6b443a81b5ad9bd0d0c704edbe96c09c9 Make InlinedVector::ShiftRight update the vector's size -... by Jon Cohen <cohenjon@google.com> - ffc2e2a6f169bbfa823890f21d13e16110cd0206 Fix issues when passing references aliasing into an Inlin... by Jon Cohen <cohenjon@google.com> - 2fce2f87043f8c044889b4aab828e6edc20da0d9 In C++14 or later, alias absl::make_unique to std::make_u... by Abseil Team <absl-team@google.com> - cb83e95b486c59fd6acfa956e97f42253dd158bd Roll back change to avoid weak virtual table warnings (-W... by Abseil Team <absl-team@google.com> - fb4ea46062895cb9340166c9dcc61ec4467bd834 Avoid weak virtual table warnings (-Wweak-vtables) and re... by Abseil Team <absl-team@google.com> GitOrigin-RevId: 989557e6b443a81b5ad9bd0d0c704edbe96c09c9 Change-Id: I6b8119c3f16e9d0cb9b5fd6e750502c9dad8e257
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 95909138..15cd85f4 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 8a5f5522..7d047ca0 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.