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
This commit is contained in:
Abseil Team 2017-10-23 11:40:35 -07:00 committed by Jon Cohen
parent 6cf9c73102
commit 5fcbe86e7b
4 changed files with 117 additions and 22 deletions

View file

@ -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()

View file

@ -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.