Blaze
3.9
Toggle main menu visibility
Loading...
Searching...
No Matches
blaze
util
algorithms
UninitializedDefaultConstruct.h
Go to the documentation of this file.
1
//=================================================================================================
33
//=================================================================================================
34
35
#ifndef _BLAZE_UTIL_ALGORITHMS_UNINITIALIZEDDEFAULTCONSTRUCT_H_
36
#define _BLAZE_UTIL_ALGORITHMS_UNINITIALIZEDDEFAULTCONSTRUCT_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_DEFAULT_CONSTRUCT ALGORITHMS
54
//
55
//=================================================================================================
56
57
//*************************************************************************************************
68
template
<
typename
ForwardIt >
69
void
uninitialized_default_construct
( ForwardIt first, ForwardIt last )
70
{
71
using
T =
typename
std::iterator_traits<ForwardIt>::value_type;
72
73
ForwardIt current( first );
74
75
try
{
76
for
( ; current!=last; ++current ) {
77
::new ( std::addressof( *current ) ) T;
78
}
79
}
80
catch
( ... ) {
81
blaze::destroy
( first, current );
82
throw
;
83
}
84
}
85
//*************************************************************************************************
86
87
88
//*************************************************************************************************
99
template
<
typename
ForwardIt >
100
void
uninitialized_default_construct_n
( ForwardIt first,
size_t
n )
101
{
102
using
T =
typename
std::iterator_traits<ForwardIt>::value_type;
103
104
ForwardIt current( first );
105
106
try
{
107
for
( ; n > 0UL; (void) ++current, --n ) {
108
::new ( std::addressof( *current ) ) T;
109
}
110
}
111
catch
( ... ) {
112
blaze::destroy
( first, current );
113
throw
;
114
}
115
}
116
//*************************************************************************************************
117
118
}
// namespace blaze
119
120
#endif
Destroy.h
Header file for the generic destroy algorithm.
blaze::uninitialized_default_construct_n
void uninitialized_default_construct_n(ForwardIt first, size_t n)
Default constructs elements in the given range.
Definition
UninitializedDefaultConstruct.h:100
blaze::destroy
void destroy(ForwardIt first, ForwardIt last)
Destroys the given range of objects .
Definition
Destroy.h:67
blaze::uninitialized_default_construct
void uninitialized_default_construct(ForwardIt first, ForwardIt last)
Default constructs elements in the given range.
Definition
UninitializedDefaultConstruct.h:69
Types.h
Header file for basic type definitions.
Generated by
1.18.0