Free Electron
|
The DepthGuard class DepthGuard takes a reference to an integer. More...
#include <depthguard.h>
Public Member Functions | |
DepthGuard (int &depth_, const Mark &mark_, const std::string &msg_) | |
DepthGuard (const DepthGuard ©_ctor)=delete | |
DepthGuard (DepthGuard &&move_ctor)=delete | |
DepthGuard & | operator= (const DepthGuard ©_assign)=delete |
DepthGuard & | operator= (DepthGuard &&move_assign)=delete |
int | current_depth () const |
Private Attributes | |
int & | m_depth |
The DepthGuard class DepthGuard takes a reference to an integer.
It increments the integer upon construction of DepthGuard and decrements the integer upon destruction.
If the integer would be incremented past max_depth, then an exception is thrown. This is ideally geared toward guarding against deep recursion.
max_depth | compile-time configurable maximum depth. |