From 000546f73ab34bc3705d7e85522c8af3a247afea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Oberhuber?= <oberhuber.tomas@gmail.com> Date: Fri, 10 Jan 2020 22:39:19 +0100 Subject: [PATCH] Added a method ArrayView::copy for shallow copy. --- src/TNL/Containers/ArrayView.h | 9 +++++++++ src/TNL/Containers/ArrayView.hpp | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/TNL/Containers/ArrayView.h b/src/TNL/Containers/ArrayView.h index c06ad56dcc..b4e063b7e9 100644 --- a/src/TNL/Containers/ArrayView.h +++ b/src/TNL/Containers/ArrayView.h @@ -237,6 +237,15 @@ public: typename = std::enable_if_t< std::is_convertible< T, ValueType >::value || IsArrayType< T >::value > > ArrayView& operator=( const T& array ); + /** + * \brief Shallow copy of the array view + * + * \param view Reference to the source array view. + * \return Reference to this array view. + */ + __cuda_callable__ + ArrayView& copy( const ArrayView& view ); + /** * \brief Swaps this array view with another. * diff --git a/src/TNL/Containers/ArrayView.hpp b/src/TNL/Containers/ArrayView.hpp index c3c39bc10b..4ef8ac3f6e 100644 --- a/src/TNL/Containers/ArrayView.hpp +++ b/src/TNL/Containers/ArrayView.hpp @@ -118,6 +118,19 @@ operator=( const T& data ) return *this; } +template< typename Value, + typename Device, + typename Index > +__cuda_callable__ +ArrayView< Value, Device, Index >& +ArrayView< Value, Device, Index >:: +copy( const ArrayView& view ) +{ + data = view.data; + size = view.size; + return *this; +} + template< typename Value, typename Device, typename Index > -- GitLab