Chemical Data Processing Library C++ API - Version 1.4.0
Public Types | Public Member Functions | Friends | List of all members
CDPL::Math::VectorReference< V > Class Template Reference

Lightweight vector expression that proxies a reference to an underlying vector container. More...

#include <Vector.hpp>

+ Inheritance diagram for CDPL::Math::VectorReference< V >:

Public Types

typedef V VectorType
 The wrapped vector type. More...
 
typedef V::ValueType ValueType
 The element value type of the wrapped vector. More...
 
typedef std::conditional< std::is_const< V >::value, typename V::ConstReference, typename V::Reference >::type Reference
 Mutable reference type (degrades to ConstReference when the wrapped vector is const). More...
 
typedef V::ConstReference ConstReference
 Constant reference type to an element. More...
 
typedef V::SizeType SizeType
 The unsigned size type of the wrapped vector. More...
 
typedef V::DifferenceType DifferenceType
 The signed difference type of the wrapped vector. More...
 
typedef SelfType ClosureType
 Closure type used when this proxy appears inside another expression. More...
 
typedef const SelfType ConstClosureType
 Constant closure type used when this proxy appears inside another expression. More...
 
- Public Types inherited from CDPL::Math::VectorExpression< VectorReference< V > >
typedef VectorReference< V > ExpressionType
 The derived vector expression type. More...
 
- Public Types inherited from CDPL::Math::Expression< E >
typedef E ExpressionType
 The derived expression type (made available to expression-template machinery). More...
 

Public Member Functions

 VectorReference (VectorType &v)
 Constructs the reference proxy referring to v. More...
 
Reference operator[] (SizeType i)
 Returns a mutable reference to the element at index i (alias for operator()). More...
 
ConstReference operator[] (SizeType i) const
 Returns a const reference to the element at index i (alias for operator()). More...
 
Reference operator() (SizeType i)
 Returns a mutable reference to the element at index i. More...
 
ConstReference operator() (SizeType i) const
 Returns a const reference to the element at index i. More...
 
SizeType getSize () const
 Returns the wrapped vector's element count. More...
 
SizeType getMaxSize () const
 Returns the wrapped vector's capacity (maximum element count without reallocation). More...
 
bool isEmpty () const
 Tells whether the wrapped vector is empty. More...
 
const VectorTypegetData () const
 Returns a const reference to the wrapped vector. More...
 
VectorTypegetData ()
 Returns a reference to the wrapped vector. More...
 
VectorReferenceoperator= (const VectorReference &r)
 Copy-assigns the wrapped vector from the vector referenced by r. More...
 
template<typename E >
VectorReferenceoperator= (const VectorExpression< E > &e)
 Assigns the vector expression e to the wrapped vector. More...
 
template<typename E >
VectorReferenceoperator+= (const VectorExpression< E > &e)
 Adds the vector expression e element-wise to the wrapped vector. More...
 
template<typename E >
VectorReferenceoperator-= (const VectorExpression< E > &e)
 Subtracts the vector expression e element-wise from the wrapped vector. More...
 
template<typename T >
std::enable_if< IsScalar< T >::value, VectorReference >::type & operator*= (const T &t)
 Multiplies every element of the wrapped vector by the scalar t. More...
 
template<typename T >
std::enable_if< IsScalar< T >::value, VectorReference >::type & operator/= (const T &t)
 Divides every element of the wrapped vector by the scalar t. More...
 
template<typename E >
VectorReferenceassign (const VectorExpression< E > &e)
 Assigns the vector expression e to the wrapped vector without intermediate temporary. More...
 
template<typename E >
VectorReferenceplusAssign (const VectorExpression< E > &e)
 Adds the vector expression e to the wrapped vector without intermediate temporary. More...
 
template<typename E >
VectorReferenceminusAssign (const VectorExpression< E > &e)
 Subtracts the vector expression e from the wrapped vector without intermediate temporary. More...
 
void swap (VectorReference &r)
 Swaps the contents of the two wrapped vectors. More...
 
- Public Member Functions inherited from CDPL::Math::VectorExpression< VectorReference< V > >
const ExpressionTypeoperator() () const
 Returns a const reference to the derived vector expression. More...
 
ExpressionTypeoperator() ()
 Returns a reference to the derived vector expression. More...
 

Friends

void swap (VectorReference &r1, VectorReference &r2)
 ADL-enabled free-function form of swap(). More...
 

Additional Inherited Members

- Protected Member Functions inherited from CDPL::Math::VectorExpression< VectorReference< V > >
 VectorExpression ()
 
 ~VectorExpression ()
 
- Protected Member Functions inherited from CDPL::Math::Expression< E >
 Expression ()
 
 ~Expression ()
 

Detailed Description

template<typename V>
class CDPL::Math::VectorReference< V >

Lightweight vector expression that proxies a reference to an underlying vector container.

Template Parameters
VThe wrapped vector type.

Member Typedef Documentation

◆ VectorType

template<typename V >
typedef V CDPL::Math::VectorReference< V >::VectorType

The wrapped vector type.

◆ ValueType

template<typename V >
typedef V::ValueType CDPL::Math::VectorReference< V >::ValueType

The element value type of the wrapped vector.

◆ Reference

template<typename V >
typedef std::conditional<std::is_const<V>::value, typename V::ConstReference, typename V::Reference>::type CDPL::Math::VectorReference< V >::Reference

Mutable reference type (degrades to ConstReference when the wrapped vector is const).

◆ ConstReference

template<typename V >
typedef V::ConstReference CDPL::Math::VectorReference< V >::ConstReference

Constant reference type to an element.

◆ SizeType

template<typename V >
typedef V::SizeType CDPL::Math::VectorReference< V >::SizeType

The unsigned size type of the wrapped vector.

◆ DifferenceType

template<typename V >
typedef V::DifferenceType CDPL::Math::VectorReference< V >::DifferenceType

The signed difference type of the wrapped vector.

◆ ClosureType

template<typename V >
typedef SelfType CDPL::Math::VectorReference< V >::ClosureType

Closure type used when this proxy appears inside another expression.

◆ ConstClosureType

template<typename V >
typedef const SelfType CDPL::Math::VectorReference< V >::ConstClosureType

Constant closure type used when this proxy appears inside another expression.

Constructor & Destructor Documentation

◆ VectorReference()

template<typename V >
CDPL::Math::VectorReference< V >::VectorReference ( VectorType v)
inlineexplicit

Constructs the reference proxy referring to v.

Parameters
vThe wrapped vector to proxy.

Member Function Documentation

◆ operator[]() [1/2]

template<typename V >
Reference CDPL::Math::VectorReference< V >::operator[] ( SizeType  i)
inline

Returns a mutable reference to the element at index i (alias for operator()).

Parameters
iThe zero-based element index.
Returns
A mutable reference to the element.

◆ operator[]() [2/2]

template<typename V >
ConstReference CDPL::Math::VectorReference< V >::operator[] ( SizeType  i) const
inline

Returns a const reference to the element at index i (alias for operator()).

Parameters
iThe zero-based element index.
Returns
A const reference to the element.

◆ operator()() [1/2]

template<typename V >
Reference CDPL::Math::VectorReference< V >::operator() ( SizeType  i)
inline

Returns a mutable reference to the element at index i.

Parameters
iThe zero-based element index.
Returns
A mutable reference to the element.

◆ operator()() [2/2]

template<typename V >
ConstReference CDPL::Math::VectorReference< V >::operator() ( SizeType  i) const
inline

Returns a const reference to the element at index i.

Parameters
iThe zero-based element index.
Returns
A const reference to the element.

◆ getSize()

template<typename V >
SizeType CDPL::Math::VectorReference< V >::getSize ( ) const
inline

Returns the wrapped vector's element count.

Returns
The number of elements.

◆ getMaxSize()

template<typename V >
SizeType CDPL::Math::VectorReference< V >::getMaxSize ( ) const
inline

Returns the wrapped vector's capacity (maximum element count without reallocation).

Returns
The maximum element count.

◆ isEmpty()

template<typename V >
bool CDPL::Math::VectorReference< V >::isEmpty ( ) const
inline

Tells whether the wrapped vector is empty.

Returns
true if the wrapped vector has zero elements, and false otherwise.

◆ getData() [1/2]

template<typename V >
const VectorType& CDPL::Math::VectorReference< V >::getData ( ) const
inline

Returns a const reference to the wrapped vector.

Returns
A const reference to the wrapped vector.

◆ getData() [2/2]

template<typename V >
VectorType& CDPL::Math::VectorReference< V >::getData ( )
inline

Returns a reference to the wrapped vector.

Returns
A reference to the wrapped vector.

◆ operator=() [1/2]

template<typename V >
VectorReference& CDPL::Math::VectorReference< V >::operator= ( const VectorReference< V > &  r)
inline

Copy-assigns the wrapped vector from the vector referenced by r.

Parameters
rThe source reference proxy.
Returns
A reference to itself.

◆ operator=() [2/2]

template<typename V >
template<typename E >
VectorReference& CDPL::Math::VectorReference< V >::operator= ( const VectorExpression< E > &  e)
inline

Assigns the vector expression e to the wrapped vector.

Template Parameters
EThe source vector expression type.
Parameters
eThe source vector expression.
Returns
A reference to itself.

◆ operator+=()

template<typename V >
template<typename E >
VectorReference& CDPL::Math::VectorReference< V >::operator+= ( const VectorExpression< E > &  e)
inline

Adds the vector expression e element-wise to the wrapped vector.

Template Parameters
EThe source vector expression type.
Parameters
eThe source vector expression.
Returns
A reference to itself.

◆ operator-=()

template<typename V >
template<typename E >
VectorReference& CDPL::Math::VectorReference< V >::operator-= ( const VectorExpression< E > &  e)
inline

Subtracts the vector expression e element-wise from the wrapped vector.

Template Parameters
EThe source vector expression type.
Parameters
eThe source vector expression.
Returns
A reference to itself.

◆ operator*=()

template<typename V >
template<typename T >
std::enable_if<IsScalar<T>::value, VectorReference>::type& CDPL::Math::VectorReference< V >::operator*= ( const T &  t)
inline

Multiplies every element of the wrapped vector by the scalar t.

Template Parameters
TThe scalar type.
Parameters
tThe scalar multiplier.
Returns
A reference to itself.

◆ operator/=()

template<typename V >
template<typename T >
std::enable_if<IsScalar<T>::value, VectorReference>::type& CDPL::Math::VectorReference< V >::operator/= ( const T &  t)
inline

Divides every element of the wrapped vector by the scalar t.

Template Parameters
TThe scalar type.
Parameters
tThe scalar divisor.
Returns
A reference to itself.

◆ assign()

template<typename V >
template<typename E >
VectorReference& CDPL::Math::VectorReference< V >::assign ( const VectorExpression< E > &  e)
inline

Assigns the vector expression e to the wrapped vector without intermediate temporary.

Template Parameters
EThe source vector expression type.
Parameters
eThe source vector expression.
Returns
A reference to itself.

◆ plusAssign()

template<typename V >
template<typename E >
VectorReference& CDPL::Math::VectorReference< V >::plusAssign ( const VectorExpression< E > &  e)
inline

Adds the vector expression e to the wrapped vector without intermediate temporary.

Template Parameters
EThe source vector expression type.
Parameters
eThe source vector expression.
Returns
A reference to itself.

◆ minusAssign()

template<typename V >
template<typename E >
VectorReference& CDPL::Math::VectorReference< V >::minusAssign ( const VectorExpression< E > &  e)
inline

Subtracts the vector expression e from the wrapped vector without intermediate temporary.

Template Parameters
EThe source vector expression type.
Parameters
eThe source vector expression.
Returns
A reference to itself.

◆ swap()

template<typename V >
void CDPL::Math::VectorReference< V >::swap ( VectorReference< V > &  r)
inline

Swaps the contents of the two wrapped vectors.

Parameters
rThe reference proxy to swap with.

Friends And Related Function Documentation

◆ swap

template<typename V >
void swap ( VectorReference< V > &  r1,
VectorReference< V > &  r2 
)
friend

ADL-enabled free-function form of swap().

Parameters
r1The first reference proxy.
r2The second reference proxy.

The documentation for this class was generated from the following file: