From 9ba6a147311eacb933c175168de6d11c439985d3 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 22 Dec 2015 14:57:45 -0800 Subject: Merge to XFA: Start using allowed C++11 features. TBR=dml@google.com, thakis@chromium.org Review URL: https://codereview.chromium.org/1544923002 . Review URL: https://codereview.chromium.org/1545823002 . (cherry picked from commit ba2586d2c0a50df14aa2549a0a841e1d4b9af4b6) (cherry picked from commit 87f7d29531dabfd66e547a6be31a08272ff631d5) Review URL: https://codereview.chromium.org/1542213002 . --- third_party/base/nonstd_unique_ptr.h | 12 +++--------- third_party/base/nonstd_unique_ptr_unittest.cpp | 7 ++++--- third_party/base/stl_util.h | 15 --------------- 3 files changed, 7 insertions(+), 27 deletions(-) (limited to 'third_party') diff --git a/third_party/base/nonstd_unique_ptr.h b/third_party/base/nonstd_unique_ptr.h index f519b345b1..f056e50397 100644 --- a/third_party/base/nonstd_unique_ptr.h +++ b/third_party/base/nonstd_unique_ptr.h @@ -74,18 +74,12 @@ #include #include +#include #include "template_util.h" namespace nonstd { -// Replacement for move, but doesn't allow things that are already -// rvalue references. -template -T&& move(T& t) { - return static_cast(t); -} - // Function object which deletes its parameter, which must be a pointer. // If C is an array type, invokes 'delete[]' on the parameter; otherwise, // invokes 'delete'. The default deleter for unique_ptr. @@ -244,7 +238,7 @@ class unique_ptr : public internal::unique_ptr_base { // Move constructor. unique_ptr(unique_ptr&& that) - : internal::unique_ptr_base(nonstd::move(that)) {} + : internal::unique_ptr_base(std::move(that)) {} // operator=. Allows assignment from a nullptr. Deletes the currently owned // object, if any. @@ -317,7 +311,7 @@ class unique_ptr : public internal::unique_ptr_base { // Move constructor. unique_ptr(unique_ptr&& that) - : internal::unique_ptr_base(nonstd::move(that)) {} + : internal::unique_ptr_base(std::move(that)) {} // operator=. Allows assignment from a nullptr. Deletes the currently owned // array, if any. diff --git a/third_party/base/nonstd_unique_ptr_unittest.cpp b/third_party/base/nonstd_unique_ptr_unittest.cpp index 2b120581f4..1dcfe48b02 100644 --- a/third_party/base/nonstd_unique_ptr_unittest.cpp +++ b/third_party/base/nonstd_unique_ptr_unittest.cpp @@ -3,6 +3,7 @@ // found in the LICENSE file. #include +#include #include "testing/gtest/include/gtest/gtest.h" #include "macros.h" @@ -65,20 +66,20 @@ TEST(UniquePtrTest, MoveTest) { EXPECT_EQ(1, constructed); EXPECT_TRUE(ptr1); - unique_ptr ptr2(nonstd::move(ptr1)); + unique_ptr ptr2(std::move(ptr1)); EXPECT_EQ(1, constructed); EXPECT_FALSE(ptr1); EXPECT_TRUE(ptr2); unique_ptr ptr3; - ptr3 = nonstd::move(ptr2); + ptr3 = std::move(ptr2); EXPECT_EQ(1, constructed); EXPECT_FALSE(ptr2); EXPECT_TRUE(ptr3); unique_ptr ptr4(new CtorDtorLogger(&constructed4)); EXPECT_EQ(1, constructed4); - ptr4 = nonstd::move(ptr3); + ptr4 = std::move(ptr3); EXPECT_EQ(0, constructed4); EXPECT_FALSE(ptr3); EXPECT_TRUE(ptr4); diff --git a/third_party/base/stl_util.h b/third_party/base/stl_util.h index 50e9341569..32656038c1 100644 --- a/third_party/base/stl_util.h +++ b/third_party/base/stl_util.h @@ -5,23 +5,8 @@ #ifndef PDFIUM_THIRD_PARTY_BASE_STL_UTIL_H_ #define PDFIUM_THIRD_PARTY_BASE_STL_UTIL_H_ -#include - namespace pdfium { -// To treat a possibly-empty vector as an array, use these functions. -// If you know the array will never be empty, you can use &*v.begin() -// directly, but that is undefined behaviour if |v| is empty. -template -inline T* vector_as_array(std::vector* v) { - return v->empty() ? nullptr : &*v->begin(); -} - -template -inline const T* vector_as_array(const std::vector* v) { - return v->empty() ? nullptr : &*v->begin(); -} - // Test to see if a set, map, hash_set or hash_map contains a particular key. // Returns true if the key is in the collection. template -- cgit v1.2.3