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
17 namespace __pstl
18 {
19 namespace __internal
20 {
21
22 //------------------------------------------------------------------------
23 // uninitialized_move
24 //------------------------------------------------------------------------
25
26 template <class _ForwardIterator, class _OutputIterator>
27 _OutputIterator
__brick_uninitialized_move(_ForwardIterator __first,_ForwardIterator __last,_OutputIterator __result,std::false_type)28 __brick_uninitialized_move(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result,
29 /*vector=*/std::false_type) noexcept
30 {
31 typedef typename std::iterator_traits<_OutputIterator>::value_type _ValueType2;
32 for (; __first != __last; ++__first, ++__result)
33 {
34 ::new (std::addressof(*__result)) _ValueType2(std::move(*__first));
35 }
36 return __result;
37 }
38
39 template <class _ForwardIterator, class _OutputIterator>
40 _OutputIterator
__brick_uninitialized_move(_ForwardIterator __first,_ForwardIterator __last,_OutputIterator __result,std::true_type)41 __brick_uninitialized_move(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result,
42 /*vector=*/std::true_type) noexcept
43 {
44 typedef typename std::iterator_traits<_OutputIterator>::value_type __ValueType2;
45 typedef typename std::iterator_traits<_ForwardIterator>::reference _ReferenceType1;
46 typedef typename std::iterator_traits<_OutputIterator>::reference _ReferenceType2;
47
48 return __unseq_backend::__simd_walk_2(
49 __first, __last - __first, __result,
50 [](_ReferenceType1 __x, _ReferenceType2 __y) { ::new (std::addressof(__y)) __ValueType2(std::move(__x)); });
51 }
52
53 } // namespace __internal
54 } // namespace __pstl
55
56 #endif /* __PSTL_memory_impl_H */
57