Jpp
Public Member Functions | Friends | List of all members
JMATH::JMath< JFirst_t, JSecond_t > Struct Template Reference

Auxiliary base class for aritmetic operations of derived class types. More...

#include <JMath.hh>

Inheritance diagram for JMATH::JMath< JFirst_t, JSecond_t >:
JTOOLS::JCollection< JElement2D< JKey_t, JHistogram_t >, JDistance_t > JTOOLS::JCollection< JElement2D< JKey_t, JValue_t >, JDistance_t > JTOOLS::JCollection< JElement2D_t > JGEOMETRY3D::JQuaternion3D JGEOMETRY3D::JQuaternion3D JGEOMETRY3D::JQuaternion3D JGEOMETRY3D::JQuaternion3D JGEOMETRY3D::JRotation3D JTOOLS::JRange< counter_type > JTOOLS::JRange< double > JTOOLS::JRange< int > JTOOLS::JRange< JAbscissa_t > JTOOLS::JRange< T, JComparator_t > JTOOLS::JTuple< T > JTOOLS::JTuple< JTypeList< JHead_t, JTail_t > > JTOOLS::JTuple< JTypeList< JHead_t, JTypeList< JTail_t, JNullType > > > JTOOLS::JTuple< JHead_t > JTOOLS::JTuple< JTail_t >

Public Member Functions

JFirst_t & mul (const JSecond_t &object)
 Multiply with object. More...
 

Friends

JFirst_t & operator*= (JFirst_t &first, const JSecond_t &second)
 Multiply with object. More...
 
JFirst_t operator* (const JFirst_t &first, const JSecond_t &second)
 Multiply objects. More...
 

Detailed Description

template<class JFirst_t, class JSecond_t>
struct JMATH::JMath< JFirst_t, JSecond_t >

Auxiliary base class for aritmetic operations of derived class types.

Specialisation of JMath for two data types.

This class provides for the object multiplication operators *= *. The template parameter should then have the member method:

      JFirst_t& mul(const JFirst_t&, const JSecond_t&);

where JFirst_t and JSecond_t refer to the first and second template parameter, respectively.

This class uses in-class friend operators (see Barton-Nackman trick).

Definition at line 26 of file JMath.hh.

Member Function Documentation

◆ mul()

template<class JFirst_t, class JSecond_t>
JFirst_t& JMATH::JMath< JFirst_t, JSecond_t >::mul ( const JSecond_t &  object)
inline

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 273 of file JMath.hh.

274  {
275  return static_cast<JFirst_t&>(*this) = JCalculator<JFirst_t>::calculator.mul(static_cast<const JFirst_t&>(*this), object);
276  }

Friends And Related Function Documentation

◆ operator*=

template<class JFirst_t, class JSecond_t>
JFirst_t& operator*= ( JFirst_t &  first,
const JSecond_t &  second 
)
friend

Multiply with object.

Parameters
firstfirst object
secondsecond object
Returns
result object

Definition at line 286 of file JMath.hh.

287  {
288  return first.mul(second);
289  }

◆ operator*

template<class JFirst_t, class JSecond_t>
JFirst_t operator* ( const JFirst_t &  first,
const JSecond_t &  second 
)
friend

Multiply objects.

Parameters
firstfirst object
secondsecond object
Returns
result object

Definition at line 299 of file JMath.hh.

300  {
301  return JFirst_t(first).mul(second);
302  }

The documentation for this struct was generated from the following file:
JMATH::JCalculator
Auxiliary class for arithmetic operations on objects.
Definition: JCalculator.hh:18