Blaze  3.6
UninitializedMove.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_UTIL_ALGORITHMS_UNINITIALIZEDMOVE_H_
36 #define _BLAZE_UTIL_ALGORITHMS_UNINITIALIZEDMOVE_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <memory>
45 
46 
47 namespace blaze {
48 
49 //=================================================================================================
50 //
51 // UNINITIALIZED_MOVE ALGORITHM
52 //
53 //=================================================================================================
54 
55 //*************************************************************************************************
68 template< typename InputIt
69  , typename ForwardIt >
70 ForwardIt uninitialized_move( InputIt first, InputIt last, ForwardIt dest )
71 {
72  using Value = typename std::iterator_traits<ForwardIt>::value_type;
73 
74  ForwardIt current( dest );
75 
76  try {
77  for( ; first!=last; ++first, ++current ) {
78  ::new ( std::addressof( *current ) ) Value( std::move( *first ) );
79  }
80  return current;
81  }
82  catch( ... ) {
83  for( ; dest != current; ++dest ) {
84  dest->~Value();
85  }
86  throw;
87  }
88 }
89 //*************************************************************************************************
90 
91 } // namespace blaze
92 
93 #endif
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
ForwardIt uninitialized_move(InputIt first, InputIt last, ForwardIt dest)
Move the elements from the given source range to the uninitialized destination range.
Definition: UninitializedMove.h:70