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


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;

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

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