GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |
GeezerVison is showing commschamp.github.io — COMMS: Custom Assertion Failure Behaviour
Loading...
Searching...
No Matches
Custom Assertion Failure Behaviour First of all, there is a need to define a custom assertion failure report class which inherits from comms::Assert and overrides pure virtual member function fail(): #include "comms/comms.h"
{
public:
MyAssert(...) {...} // The constructor may receive any parameters needed
protected:
const char* expr,
const char* file,
unsigned int line,
const char* function) override
{
... // Do the failure report
}
private:
... // Any data members
}
virtual void fail(const char *expr, const char *file, unsigned int line, const char *function)=0 Pure virtual function to be called when assertion fails. Aggregates all the includes of the COMMS library interface. The second stage is to enable/register the the custom assertion failure behaviour: int main(int argc, const char* argv[])
{
comms::EnableAssert<MyAssert> enabledAssert;
// From this point custom assertion failure bahaviour takes place.
...
}
It is also possible to override custom assertion failure behavior several times: int main(int argc, const char* argv[])
{
comms::EnableAssert<MyAssert> assert1;
// From this point custom assertion failure bahaviour takes place.
...
{
// From this point different custom assertion failure bahaviour
// defined in SomeOtherMyAssert class takes place.
...
} // assert2 is out of scope, the custom assertion failure behavior
// registered with assert1 is restored.
...
}
Generated by | |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |