summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-11-20 01:00:29 -0800
committerCommit bot <commit-bot@chromium.org>2016-11-20 01:00:29 -0800
commitd8f710cedd62c1d28beee15d7dc3d31ddd148437 (patch)
tree9ed21a220915236b2b85791ce5f25abd9a33c94e /core
parent3c3094d92e67264d8bdfcac2d8451364e73b0c82 (diff)
downloadpdfium-d8f710cedd62c1d28beee15d7dc3d31ddd148437.tar.xz
Provide perfect-forwarding in CPDF_Object templates.
We'll hit this issue when we try to make CPDF_stream ctors take other unique pointers, for example. Review-Url: https://codereview.chromium.org/2513613003
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/parser/cpdf_array.h33
-rw-r--r--core/fpdfapi/parser/cpdf_dictionary.h12
-rw-r--r--core/fpdfapi/parser/cpdf_indirect_object_holder.h12
3 files changed, 33 insertions, 24 deletions
diff --git a/core/fpdfapi/parser/cpdf_array.h b/core/fpdfapi/parser/cpdf_array.h
index 125cb4cbf8..0b16f7f21b 100644
--- a/core/fpdfapi/parser/cpdf_array.h
+++ b/core/fpdfapi/parser/cpdf_array.h
@@ -10,6 +10,7 @@
#include <memory>
#include <set>
#include <type_traits>
+#include <utility>
#include <vector>
#include "core/fpdfapi/parser/cpdf_indirect_object_holder.h"
@@ -58,39 +59,43 @@ class CPDF_Array : public CPDF_Object {
// a ByteStringPool.
template <typename T, typename... Args>
typename std::enable_if<!CanInternStrings<T>::value, T*>::type AddNew(
- Args... args) {
- return static_cast<T*>(Add(pdfium::MakeUnique<T>(args...)));
+ Args&&... args) {
+ return static_cast<T*>(
+ Add(pdfium::MakeUnique<T>(std::forward<Args>(args)...)));
}
template <typename T, typename... Args>
typename std::enable_if<CanInternStrings<T>::value, T*>::type AddNew(
- Args... args) {
- return static_cast<T*>(Add(pdfium::MakeUnique<T>(m_pPool, args...)));
+ Args&&... args) {
+ return static_cast<T*>(
+ Add(pdfium::MakeUnique<T>(m_pPool, std::forward<Args>(args)...)));
}
template <typename T, typename... Args>
typename std::enable_if<!CanInternStrings<T>::value, T*>::type SetNewAt(
size_t index,
- Args... args) {
- return static_cast<T*>(SetAt(index, pdfium::MakeUnique<T>(args...)));
+ Args&&... args) {
+ return static_cast<T*>(
+ SetAt(index, pdfium::MakeUnique<T>(std::forward<Args>(args)...)));
}
template <typename T, typename... Args>
typename std::enable_if<CanInternStrings<T>::value, T*>::type SetNewAt(
size_t index,
- Args... args) {
- return static_cast<T*>(
- SetAt(index, pdfium::MakeUnique<T>(m_pPool, args...)));
+ Args&&... args) {
+ return static_cast<T*>(SetAt(
+ index, pdfium::MakeUnique<T>(m_pPool, std::forward<Args>(args)...)));
}
template <typename T, typename... Args>
typename std::enable_if<!CanInternStrings<T>::value, T*>::type InsertNewAt(
size_t index,
- Args... args) {
- return static_cast<T*>(InsertAt(index, pdfium::MakeUnique<T>(args...)));
+ Args&&... args) {
+ return static_cast<T*>(
+ InsertAt(index, pdfium::MakeUnique<T>(std::forward<Args>(args)...)));
}
template <typename T, typename... Args>
typename std::enable_if<CanInternStrings<T>::value, T*>::type InsertNewAt(
size_t index,
- Args... args) {
- return static_cast<T*>(
- InsertAt(index, pdfium::MakeUnique<T>(m_pPool, args...)));
+ Args&&... args) {
+ return static_cast<T*>(InsertAt(
+ index, pdfium::MakeUnique<T>(m_pPool, std::forward<Args>(args)...)));
}
void RemoveAt(size_t index, size_t nCount = 1);
diff --git a/core/fpdfapi/parser/cpdf_dictionary.h b/core/fpdfapi/parser/cpdf_dictionary.h
index 5d333808b9..13cbdcf7ac 100644
--- a/core/fpdfapi/parser/cpdf_dictionary.h
+++ b/core/fpdfapi/parser/cpdf_dictionary.h
@@ -10,6 +10,7 @@
#include <map>
#include <memory>
#include <set>
+#include <utility>
#include "core/fpdfapi/parser/cpdf_object.h"
#include "core/fxcrt/cfx_string_pool_template.h"
@@ -70,15 +71,16 @@ class CPDF_Dictionary : public CPDF_Object {
template <typename T, typename... Args>
typename std::enable_if<!CanInternStrings<T>::value, T*>::type SetNewFor(
const CFX_ByteString& key,
- Args... args) {
- return static_cast<T*>(SetFor(key, pdfium::MakeUnique<T>(args...)));
+ Args&&... args) {
+ return static_cast<T*>(
+ SetFor(key, pdfium::MakeUnique<T>(std::forward<Args>(args)...)));
}
template <typename T, typename... Args>
typename std::enable_if<CanInternStrings<T>::value, T*>::type SetNewFor(
const CFX_ByteString& key,
- Args... args) {
- return static_cast<T*>(
- SetFor(key, pdfium::MakeUnique<T>(m_pPool, args...)));
+ Args&&... args) {
+ return static_cast<T*>(SetFor(
+ key, pdfium::MakeUnique<T>(m_pPool, std::forward<Args>(args)...)));
}
// Convenience functions to convert native objects to array form.
diff --git a/core/fpdfapi/parser/cpdf_indirect_object_holder.h b/core/fpdfapi/parser/cpdf_indirect_object_holder.h
index a78e6663b3..1b174d8b62 100644
--- a/core/fpdfapi/parser/cpdf_indirect_object_holder.h
+++ b/core/fpdfapi/parser/cpdf_indirect_object_holder.h
@@ -10,6 +10,7 @@
#include <map>
#include <memory>
#include <type_traits>
+#include <utility>
#include "core/fpdfapi/parser/cpdf_object.h"
#include "core/fxcrt/cfx_string_pool_template.h"
@@ -34,14 +35,15 @@ class CPDF_IndirectObjectHolder {
// handle objects that can intern strings from our ByteStringPool.
template <typename T, typename... Args>
typename std::enable_if<!CanInternStrings<T>::value, T*>::type NewIndirect(
- Args... args) {
- return static_cast<T*>(AddIndirectObject(pdfium::MakeUnique<T>(args...)));
+ Args&&... args) {
+ return static_cast<T*>(
+ AddIndirectObject(pdfium::MakeUnique<T>(std::forward<Args>(args)...)));
}
template <typename T, typename... Args>
typename std::enable_if<CanInternStrings<T>::value, T*>::type NewIndirect(
- Args... args) {
- return static_cast<T*>(
- AddIndirectObject(pdfium::MakeUnique<T>(m_pByteStringPool, args...)));
+ Args&&... args) {
+ return static_cast<T*>(AddIndirectObject(
+ pdfium::MakeUnique<T>(m_pByteStringPool, std::forward<Args>(args)...)));
}
// Takes ownership of |pObj|, returns unowned pointer to it.