summaryrefslogtreecommitdiff
path: root/third_party
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-12-22 14:44:49 -0800
committerLei Zhang <thestig@chromium.org>2015-12-22 14:44:49 -0800
commitba2586d2c0a50df14aa2549a0a841e1d4b9af4b6 (patch)
treed36be5c25b4e31db2ccd7fd1a28471fee575773d /third_party
parentbe9095d0b2819cdc88785b0b4fdfccf837eb96a9 (diff)
downloadpdfium-ba2586d2c0a50df14aa2549a0a841e1d4b9af4b6.tar.xz
Start using allowed C++11 features.
R=dml@google.com, thakis@chromium.org Review URL: https://codereview.chromium.org/1544923002 .
Diffstat (limited to 'third_party')
-rw-r--r--third_party/base/nonstd_unique_ptr.h12
-rw-r--r--third_party/base/nonstd_unique_ptr_unittest.cpp7
-rw-r--r--third_party/base/stl_util.h15
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>