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

libzypp 17.36.6

Public Types | Public Member Functions | Related Symbols | List of all members
zypp::DefaultIntegral< Tp, TInitial > Class Template Reference

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

`#include <zypp-core/base/defaultintegral.h>`

## Public Types
typedef Tp | value_type

## Public Member Functions
| DefaultIntegral (Tp val_r=TInitial)
Tp & | get ()
| Conversion to Tp.
Tp | get () const
| operator Tp & ()
| operator Tp () const
constexpr Tp | initial () const
| The initial value.
DefaultIntegral & | reset ()
| Reset to the defined initial value.

## Related Symbols
(Note that these are not member symbols.)
typedef DefaultIntegral< bool, true > | TrueBool
| `true` initialized `bool`
typedef DefaultIntegral< bool, false > | FalseBool
| `false` initialized `bool`
template<typename TIntegral>
using | ZeroInit = DefaultIntegral<TIntegral,TIntegral(0)>
| `zero` initialized `integral`

## Arithmetic operations.
`+` `-` `*` `/` are provided via conversion to Tp.
Tp | _val
DefaultIntegral & | operator= (Tp rhs)
DefaultIntegral & | operator+= (Tp rhs)
DefaultIntegral & | operator-= (Tp rhs)
DefaultIntegral & | operator*= (Tp rhs)
DefaultIntegral & | operator/= (Tp rhs)
DefaultIntegral & | operator++ ()
DefaultIntegral & | operator-- ()
DefaultIntegral | operator++ (int)
DefaultIntegral | operator-- (int)

## 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]);
zypp::Counter
Integral type with initial value 0.
Definition Counter.h:29
zypp::DefaultIntegral::DefaultIntegral
DefaultIntegral(Tp val_r=TInitial)
Definition defaultintegral.h:47

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>

Tp zypp::DefaultIntegral< Tp, TInitial >::initial | ( |  | ) | const
| inlineconstexpr

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 Symbol 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:

- zypp-core/base/defaultintegral.h