memory_impl.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #ifndef _PSTL_MEMORY_IMPL_H
  10. #define _PSTL_MEMORY_IMPL_H
  11. #include <iterator>
  12. #include "unseq_backend_simd.h"
  13. namespace __pstl
  14. {
  15. namespace __internal
  16. {
  17. //------------------------------------------------------------------------
  18. // uninitialized_move
  19. //------------------------------------------------------------------------
  20. template <class _ForwardIterator, class _OutputIterator>
  21. _OutputIterator
  22. __brick_uninitialized_move(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result,
  23. /*vector=*/std::false_type) noexcept
  24. {
  25. typedef typename std::iterator_traits<_OutputIterator>::value_type _ValueType2;
  26. for (; __first != __last; ++__first, ++__result)
  27. {
  28. ::new (std::addressof(*__result)) _ValueType2(std::move(*__first));
  29. }
  30. return __result;
  31. }
  32. template <class _ForwardIterator, class _OutputIterator>
  33. _OutputIterator
  34. __brick_uninitialized_move(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result,
  35. /*vector=*/std::true_type) noexcept
  36. {
  37. typedef typename std::iterator_traits<_OutputIterator>::value_type __ValueType2;
  38. typedef typename std::iterator_traits<_ForwardIterator>::reference _ReferenceType1;
  39. typedef typename std::iterator_traits<_OutputIterator>::reference _ReferenceType2;
  40. return __unseq_backend::__simd_walk_2(
  41. __first, __last - __first, __result,
  42. [](_ReferenceType1 __x, _ReferenceType2 __y) { ::new (std::addressof(__y)) __ValueType2(std::move(__x)); });
  43. }
  44. } // namespace __internal
  45. } // namespace __pstl
  46. #endif /* _PSTL_MEMORY_IMPL_H */