summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_array.h
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/fpdfapi/parser/cpdf_array.h
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/fpdfapi/parser/cpdf_array.h')
-rw-r--r--core/fpdfapi/parser/cpdf_array.h33
1 files changed, 19 insertions, 14 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);