libzypp  17.3.0
zypp::DefaultIntegral< Tp, TInitial > Class Template Reference

Integral type with defined initial value when default constructed. More...

#include <DefaultIntegral.h>

Public Types

typedef Tp value_type
 

Public Member Functions

 DefaultIntegral (Tp val_r=TInitial)
 
constexpr Tp initial () const
 The initial value. More...
 
DefaultIntegralreset ()
 Reset to the defined initial value. More...
 
Tp & get ()
 Conversion to Tp. More...
 
Tp get () const
 
 operator Tp & ()
 
 operator Tp () const
 
Arithmetic operations.

+ - * / are provided via conversion to Tp.

DefaultIntegraloperator= (Tp rhs)
 
DefaultIntegraloperator+= (Tp rhs)
 
DefaultIntegraloperator-= (Tp rhs)
 
DefaultIntegraloperator*= (Tp rhs)
 
DefaultIntegraloperator/= (Tp rhs)
 
DefaultIntegraloperator++ ()
 
DefaultIntegraloperator-- ()
 
DefaultIntegral operator++ (int)
 
DefaultIntegral operator-- (int)
 

Private Attributes

Tp _val
 

Related Functions

(Note that these are not member functions.)

typedef DefaultIntegral< bool, true > TrueBool
 
typedef DefaultIntegral< bool, false > FalseBool
 
template<typename TIntegral >
using ZeroInit = DefaultIntegral< TIntegral, TIntegral(0)>
 

Detailed Description

template<class Tp, Tp TInitial>
class zypp::DefaultIntegral< Tp, TInitial >

Integral type with defined initial value when default constructed.

typedef DefaultIntegral<unsigned,0> Counter;
std::map<KeyType,Counter> stats;
for ( all keys )
++(stats[key]);
Todo:

maybe specialize for bool, add logical and bit operators

let TInitial default to 0 then remove base/Counter.h

Definition at line 41 of file DefaultIntegral.h.

Member Typedef Documentation

◆ value_type

template<class Tp, Tp TInitial>
typedef Tp zypp::DefaultIntegral< Tp, TInitial >::value_type

Definition at line 44 of file DefaultIntegral.h.

Constructor & Destructor Documentation

◆ DefaultIntegral()

template<class Tp, Tp TInitial>
zypp::DefaultIntegral< Tp, TInitial >::DefaultIntegral ( Tp  val_r = TInitial)
inline

Definition at line 47 of file DefaultIntegral.h.

Member Function Documentation

◆ get() [1/2]

template<class Tp, Tp TInitial>
Tp& zypp::DefaultIntegral< Tp, TInitial >::get ( )
inline

Conversion to Tp.

Definition at line 53 of file DefaultIntegral.h.

◆ get() [2/2]

template<class Tp, Tp TInitial>
Tp zypp::DefaultIntegral< Tp, TInitial >::get ( ) const
inline

Definition at line 54 of file DefaultIntegral.h.

◆ operator Tp &()

template<class Tp, Tp TInitial>
zypp::DefaultIntegral< Tp, TInitial >::operator Tp & ( )
inline

Definition at line 56 of file DefaultIntegral.h.

◆ operator Tp()

template<class Tp, Tp TInitial>
zypp::DefaultIntegral< Tp, TInitial >::operator Tp ( ) const
inline

Definition at line 57 of file DefaultIntegral.h.

◆ initial()

template<class Tp, Tp TInitial>
constexpr Tp zypp::DefaultIntegral< Tp, TInitial >::initial ( ) const
inline

The initial value.

Definition at line 61 of file DefaultIntegral.h.

◆ reset()

template<class Tp, Tp TInitial>
DefaultIntegral& zypp::DefaultIntegral< Tp, TInitial >::reset ( )
inline

Reset to the defined initial value.

Definition at line 64 of file DefaultIntegral.h.

◆ operator=()

template<class Tp, Tp TInitial>
DefaultIntegral& zypp::DefaultIntegral< Tp, TInitial >::operator= ( Tp  rhs)
inline

Definition at line 70 of file DefaultIntegral.h.

◆ operator+=()

template<class Tp, Tp TInitial>
DefaultIntegral& zypp::DefaultIntegral< Tp, TInitial >::operator+= ( Tp  rhs)
inline

Definition at line 71 of file DefaultIntegral.h.

◆ operator-=()

template<class Tp, Tp TInitial>
DefaultIntegral& zypp::DefaultIntegral< Tp, TInitial >::operator-= ( Tp  rhs)
inline

Definition at line 72 of file DefaultIntegral.h.

◆ operator*=()

template<class Tp, Tp TInitial>
DefaultIntegral& zypp::DefaultIntegral< Tp, TInitial >::operator*= ( Tp  rhs)
inline

Definition at line 73 of file DefaultIntegral.h.

◆ operator/=()

template<class Tp, Tp TInitial>
DefaultIntegral& zypp::DefaultIntegral< Tp, TInitial >::operator/= ( Tp  rhs)
inline

Definition at line 74 of file DefaultIntegral.h.

◆ operator++() [1/2]

template<class Tp, Tp TInitial>
DefaultIntegral& zypp::DefaultIntegral< Tp, TInitial >::operator++ ( )
inline

Definition at line 76 of file DefaultIntegral.h.

◆ operator--() [1/2]

template<class Tp, Tp TInitial>
DefaultIntegral& zypp::DefaultIntegral< Tp, TInitial >::operator-- ( )
inline

Definition at line 77 of file DefaultIntegral.h.

◆ operator++() [2/2]

template<class Tp, Tp TInitial>
DefaultIntegral zypp::DefaultIntegral< Tp, TInitial >::operator++ ( int  )
inline

Definition at line 79 of file DefaultIntegral.h.

◆ operator--() [2/2]

template<class Tp, Tp TInitial>
DefaultIntegral zypp::DefaultIntegral< Tp, TInitial >::operator-- ( int  )
inline

Definition at line 80 of file DefaultIntegral.h.

Friends And Related Function Documentation

◆ TrueBool

template<class Tp, Tp TInitial>
typedef DefaultIntegral<bool,true> TrueBool
related

true initialized bool

Definition at line 88 of file DefaultIntegral.h.

◆ FalseBool

template<class Tp, Tp TInitial>
typedef DefaultIntegral<bool,false> FalseBool
related

false initialized bool

Definition at line 91 of file DefaultIntegral.h.

◆ ZeroInit

template<class Tp, Tp TInitial>
template<typename TIntegral >
using ZeroInit = DefaultIntegral<TIntegral,TIntegral(0)>
related

zero initialized integral

Definition at line 95 of file DefaultIntegral.h.

Member Data Documentation

◆ _val

template<class Tp, Tp TInitial>
Tp zypp::DefaultIntegral< Tp, TInitial >::_val
private

Definition at line 84 of file DefaultIntegral.h.


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