Loading src/TNL/Containers/Array.h +16 −0 Original line number Diff line number Diff line Loading @@ -193,6 +193,22 @@ class Array */ Array( Array&& array ); /** * \brief Copy constructor from array with different template parameters. * * \tparam Value_ Value type of the input array. * \tparam Device_ Device type of the input array. * \tparam Index_ Index type of the input array. * \tparam Allocator_ Allocator type of the input array. * \param a the input array. */ template< typename Value_, typename Device_, typename Index_, typename Allocator_ > explicit Array( const Array< Value_, Device_, Index_, Allocator_ >& a ); /** * \brief Constructor which initializes the array by copying elements from * \ref std::initializer_list, e.g. `{...}`. Loading src/TNL/Containers/Array.hpp +14 −0 Original line number Diff line number Diff line Loading @@ -132,6 +132,20 @@ Array( const Array< Value, Device, Index, Allocator >& array, Algorithms::MemoryOperations< Device >::copy( this->getData(), &array.getData()[ begin ], size ); } template< typename Value, typename Device, typename Index, typename Allocator > template< typename Value_, typename Device_, typename Index_, typename Allocator_ > Array< Value, Device, Index, Allocator >:: Array( const Array< Value_, Device_, Index_, Allocator_ >& a ) { *this = a; } template< typename Value, typename Device, typename Index, Loading src/UnitTests/Containers/ArrayTest.h +5 −0 Original line number Diff line number Diff line Loading @@ -149,6 +149,11 @@ TYPED_TEST( ArrayTest, constructors ) v.reset(); EXPECT_EQ( w.getSize(), 10 ); Containers::Array< int > int_array( 10, 1 ); ArrayType int_array_copy( int_array ); for( int i = 0; i < 10; i++ ) EXPECT_EQ( int_array_copy.getElement( i ), 1 ); ArrayType a1 { 1, 2, 3 }; EXPECT_EQ( a1.getElement( 0 ), 1 ); EXPECT_EQ( a1.getElement( 1 ), 2 ); Loading Loading
src/TNL/Containers/Array.h +16 −0 Original line number Diff line number Diff line Loading @@ -193,6 +193,22 @@ class Array */ Array( Array&& array ); /** * \brief Copy constructor from array with different template parameters. * * \tparam Value_ Value type of the input array. * \tparam Device_ Device type of the input array. * \tparam Index_ Index type of the input array. * \tparam Allocator_ Allocator type of the input array. * \param a the input array. */ template< typename Value_, typename Device_, typename Index_, typename Allocator_ > explicit Array( const Array< Value_, Device_, Index_, Allocator_ >& a ); /** * \brief Constructor which initializes the array by copying elements from * \ref std::initializer_list, e.g. `{...}`. Loading
src/TNL/Containers/Array.hpp +14 −0 Original line number Diff line number Diff line Loading @@ -132,6 +132,20 @@ Array( const Array< Value, Device, Index, Allocator >& array, Algorithms::MemoryOperations< Device >::copy( this->getData(), &array.getData()[ begin ], size ); } template< typename Value, typename Device, typename Index, typename Allocator > template< typename Value_, typename Device_, typename Index_, typename Allocator_ > Array< Value, Device, Index, Allocator >:: Array( const Array< Value_, Device_, Index_, Allocator_ >& a ) { *this = a; } template< typename Value, typename Device, typename Index, Loading
src/UnitTests/Containers/ArrayTest.h +5 −0 Original line number Diff line number Diff line Loading @@ -149,6 +149,11 @@ TYPED_TEST( ArrayTest, constructors ) v.reset(); EXPECT_EQ( w.getSize(), 10 ); Containers::Array< int > int_array( 10, 1 ); ArrayType int_array_copy( int_array ); for( int i = 0; i < 10; i++ ) EXPECT_EQ( int_array_copy.getElement( i ), 1 ); ArrayType a1 { 1, 2, 3 }; EXPECT_EQ( a1.getElement( 0 ), 1 ); EXPECT_EQ( a1.getElement( 1 ), 2 ); Loading