summaryrefslogtreecommitdiff
path: root/include/comphelper/sequence.hxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-06-14 09:35:16 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-06-14 14:17:14 +0200
commitb70fa47aec65fe95da94fc17640dda27650e9677 (patch)
tree7e54f37342fd57c324f43d54659335554a9c8e72 /include/comphelper/sequence.hxx
parent6db84250d1c4e7ec5a54ff75e124ea9a84ff89d9 (diff)
use more SAL_N_ELEMENTS part 1
- teach comphelper::containerToSequence to handle sized arrays - also use range based for-loop where appropriate. Change-Id: I73ba9b6295e7b29c872ee53de7a9340969e07f99 Reviewed-on: https://gerrit.libreoffice.org/38769 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/comphelper/sequence.hxx')
-rw-r--r--include/comphelper/sequence.hxx15
1 files changed, 12 insertions, 3 deletions
diff --git a/include/comphelper/sequence.hxx b/include/comphelper/sequence.hxx
index 68c361c6282f..8fba7b8722b1 100644
--- a/include/comphelper/sequence.hxx
+++ b/include/comphelper/sequence.hxx
@@ -283,10 +283,10 @@ namespace comphelper
truncated. There's currently no measure to prevent or detect
precision loss, overflow or truncation.
*/
- template < typename DstType, typename SrcType >
- inline css::uno::Sequence< DstType > containerToSequence( const SrcType& i_Container )
+ template < typename DstElementType, typename SrcType >
+ inline css::uno::Sequence< DstElementType > containerToSequence( const SrcType& i_Container )
{
- css::uno::Sequence< DstType > result( i_Container.size() );
+ css::uno::Sequence< DstElementType > result( i_Container.size() );
::std::copy( i_Container.begin(), i_Container.end(), result.getArray() );
return result;
}
@@ -300,6 +300,15 @@ namespace comphelper
return result;
}
+ // handle arrays
+ template<typename SrcElementType, std::size_t SrcSize>
+ inline css::uno::Sequence< SrcElementType > containerToSequence( SrcElementType const (&i_Array)[ SrcSize ] )
+ {
+ css::uno::Sequence< SrcElementType > result( SrcSize );
+ ::std::copy( std::begin(i_Array), std::end(i_Array), result.getArray() );
+ return result;
+ }
+
template <typename T>
inline css::uno::Sequence<T> containerToSequence(
::std::vector<T> const& v )