summaryrefslogtreecommitdiff
path: root/include/comphelper/sequence.hxx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2019-08-21 17:56:29 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2019-08-22 08:47:06 +0200
commit64f03e7bed015ea0626e5218c03078d08257a27f (patch)
tree1c18f78d1728fb08a0b6c432ca67b04c115f2e27 /include/comphelper/sequence.hxx
parent0d1490dbbdd6a4cbe2486f993517383cc8112003 (diff)
Use range ctor to avoid default-insertion of elements before assignment
Change-Id: I9d14ca33349ea92f94362e862fd24e1e468dab05 Reviewed-on: https://gerrit.libreoffice.org/77929 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'include/comphelper/sequence.hxx')
-rw-r--r--include/comphelper/sequence.hxx16
1 files changed, 5 insertions, 11 deletions
diff --git a/include/comphelper/sequence.hxx b/include/comphelper/sequence.hxx
index 6eadc5e917cb..6c51311daf29 100644
--- a/include/comphelper/sequence.hxx
+++ b/include/comphelper/sequence.hxx
@@ -219,15 +219,13 @@ namespace comphelper
elements
@tpl DstType
- Container type. This type must fulfill the STL container and
- sequence concepts, in particular, the begin(), end() and the
- unary constructor DstType(int) methods must be available and
- have the usual semantics.
+ Container type. This type must have a constructor taking a pair
+ of iterators defining a range to copy from
@param i_Sequence
Reference to a Sequence of SrcType elements
- @return the generated container
+ @return the generated container. C++17 copy elision rules apply
@attention this function always performs a copy. Furthermore,
when copying from e.g. a Sequence<double> to a vector<int>, no
@@ -238,18 +236,14 @@ namespace comphelper
template < typename DstType, typename SrcType >
inline DstType sequenceToContainer( const css::uno::Sequence< SrcType >& i_Sequence )
{
- DstType result( i_Sequence.getLength() );
- ::std::copy( i_Sequence.begin(), i_Sequence.end(), result.begin() );
- return result;
+ return DstType(i_Sequence.begin(), i_Sequence.end());
}
// this one does better type deduction, but does not allow us to copy into a different element type
template < typename DstType >
inline DstType sequenceToContainer( const css::uno::Sequence< typename DstType::value_type >& i_Sequence )
{
- DstType result( i_Sequence.getLength() );
- ::std::copy( i_Sequence.begin(), i_Sequence.end(), result.begin() );
- return result;
+ return DstType(i_Sequence.begin(), i_Sequence.end());
}
/** Copy from a Sequence into an existing container