Loading src/TNL/Containers/Vector.h +10 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,16 @@ public: */ Vector( Vector&& ) = default; /** * \brief Constructor from expression template * * @param expression input expression template */ template< typename VectorExpression, typename..., typename = std::enable_if_t< Expressions::HasEnabledExpressionTemplates< VectorExpression >::value && ! IsArrayType< VectorExpression >::value > > explicit Vector( const VectorExpression& expression ); /** * \brief Copy-assignment operator for copying data from another vector. */ Loading src/TNL/Containers/Vector.hpp +14 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,20 @@ Vector( const Vector& vector, { } template< typename Real, typename Device, typename Index, typename Allocator > template< typename VectorExpression, typename..., typename > Vector< Real, Device, Index, Allocator >:: Vector( const VectorExpression& expression ) { detail::VectorAssignment< Vector, VectorExpression >::resize( *this, expression ); detail::VectorAssignment< Vector, VectorExpression >::assign( *this, expression ); } template< typename Real, typename Device, typename Index, Loading src/UnitTests/Containers/VectorTest.h +6 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,12 @@ TYPED_TEST( VectorTest, constructors ) EXPECT_EQ( a3.getElement( 0 ), 7 ); EXPECT_EQ( a3.getElement( 1 ), 8 ); EXPECT_EQ( a3.getElement( 2 ), 9 ); VectorType a4( 2 * a2 + 3 * a3 ); EXPECT_EQ( a4.getElement( 0 ), 2.0 * a2.getElement( 0 ) + 3 * a3.getElement( 0 ) ); EXPECT_EQ( a4.getElement( 1 ), 2.0 * a2.getElement( 1 ) + 3 * a3.getElement( 1 ) ); EXPECT_EQ( a4.getElement( 2 ), 2.0 * a2.getElement( 2 ) + 3 * a3.getElement( 2 ) ); } TEST( VectorSpecialCasesTest, defaultConstructors ) Loading Loading
src/TNL/Containers/Vector.h +10 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,16 @@ public: */ Vector( Vector&& ) = default; /** * \brief Constructor from expression template * * @param expression input expression template */ template< typename VectorExpression, typename..., typename = std::enable_if_t< Expressions::HasEnabledExpressionTemplates< VectorExpression >::value && ! IsArrayType< VectorExpression >::value > > explicit Vector( const VectorExpression& expression ); /** * \brief Copy-assignment operator for copying data from another vector. */ Loading
src/TNL/Containers/Vector.hpp +14 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,20 @@ Vector( const Vector& vector, { } template< typename Real, typename Device, typename Index, typename Allocator > template< typename VectorExpression, typename..., typename > Vector< Real, Device, Index, Allocator >:: Vector( const VectorExpression& expression ) { detail::VectorAssignment< Vector, VectorExpression >::resize( *this, expression ); detail::VectorAssignment< Vector, VectorExpression >::assign( *this, expression ); } template< typename Real, typename Device, typename Index, Loading
src/UnitTests/Containers/VectorTest.h +6 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,12 @@ TYPED_TEST( VectorTest, constructors ) EXPECT_EQ( a3.getElement( 0 ), 7 ); EXPECT_EQ( a3.getElement( 1 ), 8 ); EXPECT_EQ( a3.getElement( 2 ), 9 ); VectorType a4( 2 * a2 + 3 * a3 ); EXPECT_EQ( a4.getElement( 0 ), 2.0 * a2.getElement( 0 ) + 3 * a3.getElement( 0 ) ); EXPECT_EQ( a4.getElement( 1 ), 2.0 * a2.getElement( 1 ) + 3 * a3.getElement( 1 ) ); EXPECT_EQ( a4.getElement( 2 ), 2.0 * a2.getElement( 2 ) + 3 * a3.getElement( 2 ) ); } TEST( VectorSpecialCasesTest, defaultConstructors ) Loading