ROSE 0.11.145.147
Public Member Functions | Public Attributes | List of all members
Rose::RecursionCounter Struct Reference

Description

Track recursion depth in a function.

Use it like this:

boost::tribool someAnalysis() {
static size_t depth = 0;
RecursionCounter recursion(depth);
if (depth > 5) // some arbitrary limit
return boost::tribool::indeterminate;
...
}
Track recursion depth in a function.

You might ask, "Why use this class instead of just saying <code>++depth</code> and <code>--depth</code>?". If you use this class you don't have to remember to decrement the depth, especially if you (or someone else) adds additional return statements later, or if anything can throw and exception.

Definition at line 23 of file RecursionCounter.h.

#include <Rose/RecursionCounter.h>

Public Member Functions

 RecursionCounter (size_t &depth)
 

Public Attributes

size_t & depth
 

Constructor & Destructor Documentation

◆ RecursionCounter()

Rose::RecursionCounter::RecursionCounter ( size_t &  depth)
inline

Definition at line 26 of file RecursionCounter.h.

◆ ~RecursionCounter()

Rose::RecursionCounter::~RecursionCounter ( )
inline

Definition at line 30 of file RecursionCounter.h.

Member Data Documentation

◆ depth

size_t& Rose::RecursionCounter::depth

Definition at line 24 of file RecursionCounter.h.


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