SPH
Public Member Functions | Friends | List of all members
OperatorTemplate< TDerived > Struct Template Reference

Class defining additional operators from existing ones. More...

#include <OperatorTemplate.h>

Public Member Functions

TDerived operator+ (const TDerived &other) const
 
TDerived & operator-= (const TDerived &other)
 
bool operator!= (const TDerived &other) const
 
TDerived operator* (const Float value) const
 
TDerived operator/ (const Float value) const
 
TDerived & operator/= (const Float value)
 

Friends

TDerived operator- (const TDerived &value1, const TDerived &value2)
 
TDerived operator* (const Float value, const TDerived &derived)
 

Detailed Description

template<typename TDerived>
struct OperatorTemplate< TDerived >

Class defining additional operators from existing ones.

Useful to define an arithmetic types, without explicitly listing all the necessary operators. The derived class can use all or just few of defined operators. The operators come in packs; if the derived class defines operators +=, OperatorTemplate also provides binary operator +. If it further defines an unary operator -, the OperatorTemplate provides operators -= and binary -.

Besides these, the class can implement operator *=(float), i.e. multiplication by scalar. The OperatorTemplate then provides binary operator *(class, float) and *(float, class), and also operator /= and operator/(class, float). This 'pack' of operators is independent from the summation/subtraction operators; both can be implemented, or just one of them.

Finally, the derived class can implement the equality operator==, the OperatorTemplate then also provides operator !=. This pair of operators is also independent from all previous operators.

Definition at line 27 of file OperatorTemplate.h.

Member Function Documentation

◆ operator!=()

template<typename TDerived >
bool OperatorTemplate< TDerived >::operator!= ( const TDerived &  other) const
inline

Definition at line 42 of file OperatorTemplate.h.

◆ operator*()

template<typename TDerived >
TDerived OperatorTemplate< TDerived >::operator* ( const Float  value) const
inline
Todo:
gcc is happy even if the operators arent defined (as long as they are not called), is this correct according to standard?

Definition at line 47 of file OperatorTemplate.h.

◆ operator+()

template<typename TDerived >
TDerived OperatorTemplate< TDerived >::operator+ ( const TDerived &  other) const
inline

Definition at line 29 of file OperatorTemplate.h.

◆ operator-=()

template<typename TDerived >
TDerived& OperatorTemplate< TDerived >::operator-= ( const TDerived &  other)
inline

Definition at line 39 of file OperatorTemplate.h.

◆ operator/()

template<typename TDerived >
TDerived OperatorTemplate< TDerived >::operator/ ( const Float  value) const
inline

Definition at line 55 of file OperatorTemplate.h.

◆ operator/=()

template<typename TDerived >
TDerived& OperatorTemplate< TDerived >::operator/= ( const Float  value)
inline

Definition at line 59 of file OperatorTemplate.h.

Friends And Related Function Documentation

◆ operator*

template<typename TDerived >
TDerived operator* ( const Float  value,
const TDerived &  derived 
)
friend

Definition at line 52 of file OperatorTemplate.h.

◆ operator-

template<typename TDerived >
TDerived operator- ( const TDerived &  value1,
const TDerived &  value2 
)
friend

Definition at line 34 of file OperatorTemplate.h.


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