include/comphelper/sequence.hxx | 16 +++++----------- include/drawinglayer/primitive2d/baseprimitive2d.hxx | 2 ++ include/drawinglayer/primitive3d/baseprimitive3d.hxx | 2 ++ 3 files changed, 9 insertions(+), 11 deletions(-)
New commits: commit 64f03e7bed015ea0626e5218c03078d08257a27f Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Aug 21 17:56:29 2019 +0200 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Thu Aug 22 08:47:06 2019 +0200 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.kagan...@collabora.com> 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 diff --git a/include/drawinglayer/primitive2d/baseprimitive2d.hxx b/include/drawinglayer/primitive2d/baseprimitive2d.hxx index 67a40d77e4c6..5725908fb523 100644 --- a/include/drawinglayer/primitive2d/baseprimitive2d.hxx +++ b/include/drawinglayer/primitive2d/baseprimitive2d.hxx @@ -79,6 +79,8 @@ namespace drawinglayer { namespace primitive2d { Primitive2DContainer( const Primitive2DContainer&& other ) : deque(other) {} Primitive2DContainer( const std::deque< Primitive2DReference >& other ) : deque(other) {} Primitive2DContainer( std::initializer_list<Primitive2DReference> init ) : deque(init) {} + template <class Iter> + Primitive2DContainer(Iter first, Iter last) : deque(first, last) {} virtual void append(const Primitive2DReference&) override; virtual void append(const Primitive2DContainer& rSource) override; diff --git a/include/drawinglayer/primitive3d/baseprimitive3d.hxx b/include/drawinglayer/primitive3d/baseprimitive3d.hxx index 4e93523f8e8e..70c9f63ab1af 100644 --- a/include/drawinglayer/primitive3d/baseprimitive3d.hxx +++ b/include/drawinglayer/primitive3d/baseprimitive3d.hxx @@ -62,6 +62,8 @@ namespace drawinglayer { namespace primitive3d { Primitive3DContainer( const Primitive3DContainer& other ) : deque(other) {} Primitive3DContainer( const Primitive3DContainer&& other ) : deque(other) {} Primitive3DContainer( std::initializer_list<Primitive3DReference> init ) : deque(init) {} + template <class Iter> + Primitive3DContainer(Iter first, Iter last) : deque(first, last) {} void append(const Primitive3DContainer& rSource); Primitive3DContainer& operator=(const Primitive3DContainer& r) { deque::operator=(r); return *this; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits