dune-fem 2.8.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
Dune::Fem::DebugCounter< CounterImp > Class Template Reference

A counter only present if NDEBUG is not defined. More...

#include <dune/fem/misc/debug.hh>

Inheritance diagram for Dune::Fem::DebugCounter< CounterImp >:
Inheritance graph

Public Types

typedef CounterImp CounterType
 integral type for the actual counting
 

Public Member Functions

 DebugCounter (const CounterType count=0)
 constructor
 
 DebugCounter (const ThisType &other)
 copy constructor
 
ThisTypeoperator++ ()
 increment operator
 
ThisTypeoperator-- ()
 decrement operator
 
bool operator== (const ThisType &other)
 comparison for equality
 
bool operator!= (const ThisType &other)
 comparison for inequality
 

Protected Attributes

CounterType count_
 

Detailed Description

template<class CounterImp = unsigned int>
class Dune::Fem::DebugCounter< CounterImp >

A counter only present if NDEBUG is not defined.

There are several cases, where we need a counter for debugging purposes that should only be present, if NDEBUG is not defined.

In debug mode, this counter wraps a standard integer type, otherwise its size is zero.

Note
The comparison operators always return true, if NDEBUG is defined!

Member Typedef Documentation

◆ CounterType

template<class CounterImp = unsigned int>
typedef CounterImp Dune::Fem::DebugCounter< CounterImp >::CounterType

integral type for the actual counting

Constructor & Destructor Documentation

◆ DebugCounter() [1/2]

template<class CounterImp = unsigned int>
Dune::Fem::DebugCounter< CounterImp >::DebugCounter ( const CounterType  count = 0)
inline

constructor

Note
This constructor implicitly defines a conversion from CounterType to DebugCounter. This is very useful in comparison statements.
Parameters
[in]countvalue to initialize the counter with (defaults to 0)

◆ DebugCounter() [2/2]

template<class CounterImp = unsigned int>
Dune::Fem::DebugCounter< CounterImp >::DebugCounter ( const ThisType other)
inline

copy constructor

Member Function Documentation

◆ operator!=()

template<class CounterImp = unsigned int>
bool Dune::Fem::DebugCounter< CounterImp >::operator!= ( const ThisType other)
inline

comparison for inequality

Compares to DebugCounters for inequality. If USE_DEBUG_CNT is defined, the result will be true.

Note
Due to the implicit conversion, the second argument may also be of CounterType.
Parameters
[in]otherDebugCounter to compare this one to
Returns
true, if the counters differ or USE_DEBUG_CNT is defined

◆ operator++()

template<class CounterImp = unsigned int>
ThisType & Dune::Fem::DebugCounter< CounterImp >::operator++ ( )
inline

increment operator

If USE_DEBUG_CNT is not defined, the counter is incremented by 1. Otherwise nothing happens (and the entire call will be removed during oprimization).

◆ operator--()

template<class CounterImp = unsigned int>
ThisType & Dune::Fem::DebugCounter< CounterImp >::operator-- ( )
inline

decrement operator

If USE_DEBUG_CNT is not defined, the counter is decremented by 1. Otherwise nothing happens (and the entire call will be removed during oprimization).

◆ operator==()

template<class CounterImp = unsigned int>
bool Dune::Fem::DebugCounter< CounterImp >::operator== ( const ThisType other)
inline

comparison for equality

Compares to DebugCounters for equality. If USE_DEBUG_CNT is defined, the result will be true.

Note
Due to the implicit conversion, the second argument may also be of CounterType.
Parameters
[in]otherDebugCounter to compare this one to
Returns
true, if the counters equal or USE_DEBUG_CNT is defined

Member Data Documentation

◆ count_

template<class CounterImp = unsigned int>
CounterType Dune::Fem::DebugCounter< CounterImp >::count_
protected

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