Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Using User


Invariant()

This function is used to panic the current thread with a USER 0 panic. Typically, this is called when a test for a class invariant fails, i.e. when a test which checks that the internal data of an object is self-consistent, fails. Such tests are almost always done in debug builds, commonly using the __ASSERT_DEBUG macro.

For example, a class invariant might be that data member iX is always positive; the member function MyFun() could include a test for this:

void CMyClass::MyFun(...)
 {
 __ASSERT_DEBUG(iX >= 0,User::Invariant());
 ...
 /* Main body of function */
 ...
 }