Belle II Software development
Scalar< T > Class Template Reference

Class wrapping a scalar type (for which std::is_scalar is true). More...

#include <Scalar.h>

Public Member Functions

 Scalar (T obj)
 Wrap scalar type as an object.
 
 operator T& () &
 Allow unpacking.
 
 operator T const & () const &
 Allow const unpacking.
 
operator-> () const
 Mimic the original item pointer access for the cast that T is a pointer.
 
std::remove_pointer< T >::type & operator* () const
 Dereferencing access for the case that T is a pointer.
 
bool operator< (const Scalar< T > &rhs) const
 Transport ordering.
 
bool operator== (const Scalar< T > &rhs) const
 Transport equality.
 

Private Attributes

m_obj
 Memory for the underlying scalar type.
 

Detailed Description

template<class T>
class Belle2::TrackFindingCDC::Scalar< T >

Class wrapping a scalar type (for which std::is_scalar is true).

Needed because you cannot inherit from scalar type directly in a mixin based inheritance structure. It does not support all the basic operations, but transparently unpacks if conversion to the underlying type is requested by the using context.

Definition at line 28 of file Scalar.h.

Constructor & Destructor Documentation

◆ Scalar()

Scalar ( obj)
inlineexplicit

Wrap scalar type as an object.

Definition at line 31 of file Scalar.h.

32 : m_obj(obj)
33 {
34 }
T m_obj
Memory for the underlying scalar type.
Definition: Scalar.h:73

Member Function Documentation

◆ operator T const &()

operator T const & ( ) const &
inline

Allow const unpacking.

Definition at line 42 of file Scalar.h.

43 {
44 return m_obj;
45 }

◆ operator T&()

operator T& ( ) &
inline

Allow unpacking.

Definition at line 37 of file Scalar.h.

37 {
38 return m_obj;
39 }

◆ operator*()

std::remove_pointer< T >::type & operator* ( ) const
inline

Dereferencing access for the case that T is a pointer.

Definition at line 54 of file Scalar.h.

55 {
56 return *m_obj;
57 }

◆ operator->()

T operator-> ( ) const
inline

Mimic the original item pointer access for the cast that T is a pointer.

Definition at line 48 of file Scalar.h.

49 {
50 return m_obj;
51 }

◆ operator<()

bool operator< ( const Scalar< T > &  rhs) const
inline

Transport ordering.

Definition at line 60 of file Scalar.h.

61 {
62 return m_obj < rhs.m_obj;
63 }

◆ operator==()

bool operator== ( const Scalar< T > &  rhs) const
inline

Transport equality.

Definition at line 66 of file Scalar.h.

67 {
68 return m_obj == rhs.m_obj;
69 }

Member Data Documentation

◆ m_obj

T m_obj
private

Memory for the underlying scalar type.

Definition at line 73 of file Scalar.h.


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