Blaze
3.9
Toggle main menu visibility
Loading...
Searching...
No Matches
blaze
util
algorithms
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
#include <
blaze/util/algorithms/Destroy.h
>
46
#include <
blaze/util/Types.h
>
47
48
49
namespace
blaze {
50
51
//=================================================================================================
52
//
53
// UNINITIALIZED_MOVE ALGORITHMS
54
//
55
//=================================================================================================
56
57
//*************************************************************************************************
70
template
<
typename
InputIt
71
,
typename
ForwardIt >
72
ForwardIt
uninitialized_move
( InputIt first, InputIt last, ForwardIt dest )
73
{
74
using
T =
typename
std::iterator_traits<ForwardIt>::value_type;
75
76
ForwardIt current( dest );
77
78
try
{
79
for
( ; first!=last; ++first, ++current ) {
80
::new ( std::addressof( *current ) ) T( std::move( *first ) );
81
}
82
return
current;
83
}
84
catch
( ... ) {
85
blaze::destroy
( dest, current );
86
throw
;
87
}
88
}
89
//*************************************************************************************************
90
91
92
//*************************************************************************************************
105
template
<
typename
InputIt
106
,
typename
ForwardIt >
107
ForwardIt
uninitialized_move_n
( InputIt first,
size_t
n, ForwardIt dest )
108
{
109
using
T =
typename
std::iterator_traits<ForwardIt>::value_type;
110
111
ForwardIt current( dest );
112
113
try
{
114
for
( ; n > 0UL; (void) ++first, (void) ++current, --n ) {
115
::new ( std::addressof( *current ) ) T( std::move( *first ) );
116
}
117
return
current;
118
}
119
catch
( ... ) {
120
blaze::destroy
( dest, current );
121
throw
;
122
}
123
}
124
//*************************************************************************************************
125
126
}
// namespace blaze
127
128
#endif
Destroy.h
Header file for the generic destroy algorithm.
blaze::destroy
void destroy(ForwardIt first, ForwardIt last)
Destroys the given range of objects .
Definition
Destroy.h:67
blaze::uninitialized_move
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:72
blaze::uninitialized_move_n
ForwardIt uninitialized_move_n(InputIt first, size_t n, ForwardIt dest)
Move the elements from the given source range to the uninitialized destination range.
Definition
UninitializedMove.h:107
Types.h
Header file for basic type definitions.
Generated by
1.18.0