version 0.4.1
ScalarWrapper< T > Class Template Reference

A wrapper class for scalar types to facilitate reference passing in Python bindings. More...

#include <ikarus/python/finiteelements/scalarwrapper.hh>

Public Types

using RawScalarType = Dune::ResolveRef_t< T >
 

Public Member Functions

 ScalarWrapper (T val)
 Constructs a ScalarWrapper with the given value. More...
 
 operator RawScalarType & () const
 Implicitly converts the wrapper to a reference of the raw scalar type. More...
 
const RawScalarTypevalue () const
 Gets the wrapped scalar value as a constant reference. More...
 
RawScalarTypevalue ()
 Gets the wrapped scalar value as a reference. More...
 
RawScalarType operator+ (const ScalarWrapper &v) const
 Adds the values of two ScalarWrapper instances. This returns the raw type since this makes makes no since when T is of reference_wrapper type. More...
 
RawScalarType operator- (const ScalarWrapper &v) const
 Subtracts the value of another ScalarWrapper from this instance. More...
 
RawScalarType operator- () const
 Negates the wrapped scalar value. More...
 
RawScalarType operator* (RawScalarType value) const
 Multiplies the wrapped scalar value by another value. More...
 
ScalarWrapperoperator+= (const ScalarWrapper &v)
 Adds another ScalarWrapper's value to this instance. More...
 
ScalarWrapperoperator-= (const ScalarWrapper &v)
 Subtracts another ScalarWrapper's value from this instance. More...
 
ScalarWrapperoperator*= (RawScalarType v)
 Multiplies the wrapped scalar value by another value and assigns the result. More...
 
ScalarWrapperoperator/= (RawScalarType v)
 Divides the wrapped scalar value by another value and assigns the result. More...
 

Detailed Description

template<typename T>
class ScalarWrapper< T >

This class resolves the limitations involving reference arguments in Python, enabling seamless integration with C++ functions expecting reference types.

Template Parameters
TThe type of the scalar to be wrapped.

Member Typedef Documentation

◆ RawScalarType

template<typename T >
using ScalarWrapper< T >::RawScalarType = Dune::ResolveRef_t<T>

Constructor & Destructor Documentation

◆ ScalarWrapper()

template<typename T >
ScalarWrapper< T >::ScalarWrapper ( val)
inline
Parameters
valThe initial value of the wrapped scalar.

Member Function Documentation

◆ operator RawScalarType &()

template<typename T >
ScalarWrapper< T >::operator RawScalarType & ( ) const
inline
Returns
A reference to the wrapped scalar value.

◆ operator*()

template<typename T >
RawScalarType ScalarWrapper< T >::operator* ( RawScalarType  value) const
inline
Parameters
valueThe value to multiply with.
Returns
The result of the multiplication.

◆ operator*=()

template<typename T >
ScalarWrapper & ScalarWrapper< T >::operator*= ( RawScalarType  v)
inline
Parameters
vThe value to multiply with.
Returns
A reference to this instance after the multiplication.

◆ operator+()

template<typename T >
RawScalarType ScalarWrapper< T >::operator+ ( const ScalarWrapper< T > &  v) const
inline
Parameters
vAnother ScalarWrapper instance.
Returns
The result of the addition as a new scalar value.

◆ operator+=()

template<typename T >
ScalarWrapper & ScalarWrapper< T >::operator+= ( const ScalarWrapper< T > &  v)
inline
Parameters
vAnother ScalarWrapper instance.
Returns
A reference to this instance after the addition.

◆ operator-() [1/2]

template<typename T >
RawScalarType ScalarWrapper< T >::operator- ( ) const
inline
Returns
The negated scalar value.

◆ operator-() [2/2]

template<typename T >
RawScalarType ScalarWrapper< T >::operator- ( const ScalarWrapper< T > &  v) const
inline
Parameters
vAnother ScalarWrapper instance.
Returns
The result of the subtraction as a new scalar value.

◆ operator-=()

template<typename T >
ScalarWrapper & ScalarWrapper< T >::operator-= ( const ScalarWrapper< T > &  v)
inline
Parameters
vAnother ScalarWrapper instance.
Returns
A reference to this instance after the subtraction.

◆ operator/=()

template<typename T >
ScalarWrapper & ScalarWrapper< T >::operator/= ( RawScalarType  v)
inline
Parameters
vThe value to divide by.
Returns
A reference to this instance after the division.

◆ value() [1/2]

template<typename T >
RawScalarType & ScalarWrapper< T >::value ( )
inline
Returns
A reference to the wrapped scalar value.

◆ value() [2/2]

template<typename T >
const RawScalarType & ScalarWrapper< T >::value ( ) const
inline
Returns
A constant reference to the wrapped scalar value.
Here is the caller graph for this function:

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