source: Daodan/MSYS2/mingw32/include/c++/11.2.0/pstl/memory_impl.h@ 1170

Last change on this file since 1170 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 4.0 KB
Line 
1// -*- C++ -*-
2//===-- memory_impl.h -----------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _PSTL_MEMORY_IMPL_H
11#define _PSTL_MEMORY_IMPL_H
12
13#include <iterator>
14
15#include "unseq_backend_simd.h"
16
17namespace __pstl
18{
19namespace __internal
20{
21
22//------------------------------------------------------------------------
23// uninitialized_move
24//------------------------------------------------------------------------
25
26template <typename _ForwardIterator, typename _OutputIterator>
27_OutputIterator
28__brick_uninitialized_move(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result,
29 /*vector=*/std::false_type) noexcept
30{
31 using _ValueType = typename std::iterator_traits<_OutputIterator>::value_type;
32 for (; __first != __last; ++__first, ++__result)
33 {
34 ::new (std::addressof(*__result)) _ValueType(std::move(*__first));
35 }
36 return __result;
37}
38
39template <typename _ForwardIterator, typename _OutputIterator>
40_OutputIterator
41__brick_uninitialized_move(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result,
42 /*vector=*/std::true_type) noexcept
43{
44 using __ValueType = typename std::iterator_traits<_OutputIterator>::value_type;
45 using _ReferenceType1 = typename std::iterator_traits<_ForwardIterator>::reference;
46 using _ReferenceType2 = typename std::iterator_traits<_OutputIterator>::reference;
47
48 return __unseq_backend::__simd_walk_2(
49 __first, __last - __first, __result,
50 [](_ReferenceType1 __x, _ReferenceType2 __y) { ::new (std::addressof(__y)) __ValueType(std::move(__x)); });
51}
52
53template <typename _Iterator>
54void
55__brick_destroy(_Iterator __first, _Iterator __last, /*vector*/ std::false_type) noexcept
56{
57 using _ValueType = typename std::iterator_traits<_Iterator>::value_type;
58
59 for (; __first != __last; ++__first)
60 __first->~_ValueType();
61}
62
63template <typename _Iterator>
64void
65__brick_destroy(_Iterator __first, _Iterator __last, /*vector*/ std::true_type) noexcept
66{
67 using _ValueType = typename std::iterator_traits<_Iterator>::value_type;
68 using _ReferenceType = typename std::iterator_traits<_Iterator>::reference;
69
70 __unseq_backend::__simd_walk_1(__first, __last - __first, [](_ReferenceType __x) { __x.~_ValueType(); });
71}
72
73//------------------------------------------------------------------------
74// uninitialized copy
75//------------------------------------------------------------------------
76
77template <typename _ForwardIterator, typename _OutputIterator>
78_OutputIterator
79__brick_uninitialized_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result,
80 /*vector=*/std::false_type) noexcept
81{
82 using _ValueType = typename std::iterator_traits<_OutputIterator>::value_type;
83 for (; __first != __last; ++__first, ++__result)
84 {
85 ::new (std::addressof(*__result)) _ValueType(*__first);
86 }
87 return __result;
88}
89
90template <typename _ForwardIterator, typename _OutputIterator>
91_OutputIterator
92__brick_uninitialized_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result,
93 /*vector=*/std::true_type) noexcept
94{
95 using __ValueType = typename std::iterator_traits<_OutputIterator>::value_type;
96 using _ReferenceType1 = typename std::iterator_traits<_ForwardIterator>::reference;
97 using _ReferenceType2 = typename std::iterator_traits<_OutputIterator>::reference;
98
99 return __unseq_backend::__simd_walk_2(
100 __first, __last - __first, __result,
101 [](_ReferenceType1 __x, _ReferenceType2 __y) { ::new (std::addressof(__y)) __ValueType(__x); });
102}
103
104} // namespace __internal
105} // namespace __pstl
106
107#endif /* _PSTL_MEMORY_IMPL_H */
Note: See TracBrowser for help on using the repository browser.