diff options
author | Lei Zhang <thestig@chromium.org> | 2015-12-22 14:57:45 -0800 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-12-22 14:57:45 -0800 |
commit | 9ba6a147311eacb933c175168de6d11c439985d3 (patch) | |
tree | a1a75ac52168294f73b6eda5c65c26e4444b4c47 /third_party/base | |
parent | cd2bb30aba89a05c0bbd4d6973fa070205e3a1e8 (diff) | |
download | pdfium-9ba6a147311eacb933c175168de6d11c439985d3.tar.xz |
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 .
Diffstat (limited to 'third_party/base')
-rw-r--r-- | third_party/base/nonstd_unique_ptr.h | 12 | ||||
-rw-r--r-- | third_party/base/nonstd_unique_ptr_unittest.cpp | 7 | ||||
-rw-r--r-- | third_party/base/stl_util.h | 15 |
3 files changed, 7 insertions, 27 deletions
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 <stdlib.h> #include <ostream> +#include <utility> #include "template_util.h" namespace nonstd { -// Replacement for move, but doesn't allow things that are already -// rvalue references. -template <class T> -T&& move(T& t) { - return static_cast<T&&>(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<T>. @@ -244,7 +238,7 @@ class unique_ptr : public internal::unique_ptr_base<C, D> { // Move constructor. unique_ptr(unique_ptr&& that) - : internal::unique_ptr_base<C, D>(nonstd::move(that)) {} + : internal::unique_ptr_base<C, D>(std::move(that)) {} // operator=. Allows assignment from a nullptr. Deletes the currently owned // object, if any. @@ -317,7 +311,7 @@ class unique_ptr<C[], D> : public internal::unique_ptr_base<C, D> { // Move constructor. unique_ptr(unique_ptr&& that) - : internal::unique_ptr_base<C, D>(nonstd::move(that)) {} + : internal::unique_ptr_base<C, D>(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 <sstream> +#include <utility> #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<CtorDtorLogger> ptr2(nonstd::move(ptr1)); + unique_ptr<CtorDtorLogger> ptr2(std::move(ptr1)); EXPECT_EQ(1, constructed); EXPECT_FALSE(ptr1); EXPECT_TRUE(ptr2); unique_ptr<CtorDtorLogger> ptr3; - ptr3 = nonstd::move(ptr2); + ptr3 = std::move(ptr2); EXPECT_EQ(1, constructed); EXPECT_FALSE(ptr2); EXPECT_TRUE(ptr3); unique_ptr<CtorDtorLogger> 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 <vector> - 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 <typename T> -inline T* vector_as_array(std::vector<T>* v) { - return v->empty() ? nullptr : &*v->begin(); -} - -template <typename T> -inline const T* vector_as_array(const std::vector<T>* 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 <typename Collection, typename Key> |