Commit 4af28656 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Revised inherited constructors and operators in StaticVector

parent 84623714
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -36,11 +36,7 @@ public:
   __cuda_callable__
   static constexpr int getSize();

   /**
    * \brief Basic constructor.
    *
    * Constructs an empty static array.
    */
   //! \brief Default constructor.
   __cuda_callable__
   inline StaticArray();

@@ -48,7 +44,6 @@ public:
    * \brief Constructor that sets all array components (with the number of \e Size) to value \e v.
    *
    * Once this static array is constructed, its size can not be changed.
    * \tparam _unused
    * \param v[Size]
    */
   // Note: the template avoids ambiguity of overloaded functions with literal 0 and pointer
+3 −4
Original line number Diff line number Diff line
@@ -102,10 +102,9 @@ constexpr int StaticArray< Size, Value >::getSize()

template< int Size, typename Value >
__cuda_callable__
inline StaticArray< Size, Value >::StaticArray()
StaticArray< Size, Value >::StaticArray()
{
};

}

template< int Size, typename Value >
   template< typename _unused >
@@ -330,7 +329,7 @@ std::ostream& operator<<( std::ostream& str, const StaticArray< Size, Value >& a
   a.write( str, ", " );
   str << " ]";
   return str;
};
}

} // namespace Containers
} // namespace TNL
+16 −61
Original line number Diff line number Diff line
@@ -30,68 +30,23 @@ public:
   using RealType = Real;
   using IndexType = int;

   using StaticArray< Size, Real >::getSize;
   //using StaticArray< Size, Real >::operator ==;
   //using StaticArray< Size, Real >::operator !=;

   /**
    * \brief Basic constructor.
    *
    * Constructs an empty static vector.
    */
   __cuda_callable__
   StaticVector();

   /**
    * \brief Constructor that sets all vector components (with the number of \e Size) to value \e v.
    *
    * Once this static array is constructed, its size can not be changed.
    * \tparam _unused
    * \param v[Size]
    */
   // Note: the template avoids ambiguity of overloaded functions with literal 0 and pointer
   // reference: https://stackoverflow.com/q/4610503
   template< typename _unused = void >
   __cuda_callable__
   StaticVector( const Real v[ Size ] );

   /**
    * \brief Constructor that sets all vector components to value \e v.
    *
    * \param v Reference to a value.
    */
   //! \brief Default constructor.
   __cuda_callable__
   StaticVector( const Real& v );
   StaticVector() = default;

   /**
    * \brief Copy constructor.
    *
    * Constructs a copy of another static vector \e v.
    */
   //! \brief Default copy constructor.
   __cuda_callable__
   StaticVector( const StaticVector< Size, Real >& v );
   StaticVector( const StaticVector& ) = default;

   StaticVector( const std::initializer_list< Real > &elems );
   //! \brief Default copy-assignment operator.
   StaticVector& operator=( const StaticVector& ) = default;

   /**
    * \brief Constructor that sets components of arrays with Size = 2.
    *
    * \param v1 Real of the first array component.
    * \param v2 Real of the second array component.
    */
   __cuda_callable__
   inline StaticVector( const Real& v1, const Real& v2 );

   /**
    * \brief Constructor that sets components of arrays with Size = 3.
    *
    * \param v1 Real of the first array component.
    * \param v2 Real of the second array component.
    * \param v3 Real of the third array component.
    */
   __cuda_callable__
   inline StaticVector( const Real& v1, const Real& v2, const Real& v3 );
   //! \brief Default move-assignment operator.
   StaticVector& operator=( StaticVector&& ) = default;

   //! Constructors and assignment operators are inherited from the class \ref StaticArray.
   using StaticArray< Size, Real >::StaticArray;
   using StaticArray< Size, Real >::operator=;

   template< typename T1,
             typename T2,
+7 −55
Original line number Diff line number Diff line
@@ -33,54 +33,6 @@ auto scalarMultiplicationLambda = [] __cuda_callable__ ( int i, LeftReal* data,

} // namespace detail

template< int Size, typename Real >
__cuda_callable__
StaticVector< Size, Real >::StaticVector()
{
}

template< int Size, typename Real >
   template< typename _unused >
__cuda_callable__
StaticVector< Size, Real >::StaticVector( const Real v[ Size ] )
: StaticArray< Size, Real >( v )
{
}

template< int Size, typename Real >
__cuda_callable__
StaticVector< Size, Real >::StaticVector( const Real& v )
: StaticArray< Size, Real >( v )
{
}

template< int Size, typename Real >
__cuda_callable__
StaticVector< Size, Real >::StaticVector( const StaticVector< Size, Real >& v )
: StaticArray< Size, Real >( v )
{
}

template< int Size, typename Real >
StaticVector< Size, Real >::StaticVector( const std::initializer_list< Real > &elems )
: StaticArray< Size, Real >( elems )
{
}

template< int Size, typename Real >
 __cuda_callable__
StaticVector< Size, Real >::StaticVector( const Real& v1, const Real& v2 )
: StaticArray< Size, Real >( v1, v2 )
{
}

template< int Size, typename Real >
 __cuda_callable__
StaticVector< Size, Real >::StaticVector( const Real& v1, const Real& v2, const Real& v3 )
: StaticArray< Size, Real >( v1, v2, v3 )
{
}

template< int Size, typename Real >
   template< typename T1,
             typename T2,
@@ -88,7 +40,7 @@ template< int Size, typename Real >
StaticVector< Size, Real >::StaticVector( const Expressions::StaticBinaryExpressionTemplate< T1, T2, Operation >& op )
{
   Algorithms::VectorAssignment< StaticVector< Size, Real >, Expressions::StaticBinaryExpressionTemplate< T1, T2, Operation > >::assignStatic( *this, op );
};
}

template< int Size,
          typename Real >
@@ -98,7 +50,7 @@ __cuda_callable__
StaticVector< Size, Real >::StaticVector( const Expressions::StaticUnaryExpressionTemplate< T, Operation >& op )
{
   Algorithms::VectorAssignment< StaticVector< Size, Real >, Expressions::StaticUnaryExpressionTemplate< T, Operation > >::assignStatic( *this, op );
};
}

template< int Size, typename Real >
bool