Blaze 3.9
Transfer.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_UTIL_ALGORITHMS_TRANSFER_H_
36#define _BLAZE_UTIL_ALGORITHMS_TRANSFER_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <algorithm>
44#include <iterator>
46
47
48namespace blaze {
49
50//=================================================================================================
51//
52// TRANSFER ALGORITHM
53//
54//=================================================================================================
55
56//*************************************************************************************************
69template< typename InputIterator
70 , typename OutputIterator >
71OutputIterator transfer( InputIterator first, InputIterator last, OutputIterator dest )
72{
73 using T = typename std::iterator_traits<InputIterator>::value_type;
74
75 if( IsNothrowMoveAssignable_v<T> ) {
76 return std::move( first, last, dest );
77 }
78 else {
79 return std::copy( first, last, dest );
80 }
81}
82//*************************************************************************************************
83
84
85//*************************************************************************************************
98template< typename InputIterator
99 , typename OutputIterator >
100OutputIterator transfer_n( InputIterator first, size_t n, OutputIterator dest )
101{
102 using T = typename std::iterator_traits<InputIterator>::value_type;
103
104 if( IsNothrowMoveAssignable_v<T> ) {
105 return std::copy_n( std::make_move_iterator( first ), n, dest );
106 }
107 else {
108 return std::copy_n( first, n, dest );
109 }
110}
111//*************************************************************************************************
112
113} // namespace blaze
114
115#endif
Header file for the IsAssignable type trait.
OutputIterator transfer_n(InputIterator first, size_t n, OutputIterator dest)
Transfers the elements from the given source range to the destination range.
Definition: Transfer.h:100
OutputIterator transfer(InputIterator first, InputIterator last, OutputIterator dest)
Transfers the elements from the given source range to the destination range.
Definition: Transfer.h:71