C++ API

These are wrappers around the C API calls which simplify instrumentation of C++ source code and ensure correct tracing if exceptions are used. Because all the member functions are provided as inline functions it is sufficient to include VT.h to use these classes with every C++ compiler.

Here are some examples how the C++ API can be used. nohandles() uses the simpler interface without storing handles, while handles() saves these handles in static instances of the definition classes for later reuse when the function is called again:

void nohandles()
{
   VT_Function func( "nohandles", "C++ API", __FILE__, __LINE__ );
}
void handles()
{
   static VT_SclDef scldef( __FILE__, __LINE__ );
      // VT_SCL_DEF_CXX( scldef ) could be used instead
   static VT_FuncDef funcdef( "handles", "C++ API" );
   VT_Function func( funcdef, scldef );
}
int main( int argc, char **argv )
{
   VT_Region region( "call nohandles()", "main" );
   nohandles();
   region.end();
   handles();
   handles();
   return 0;
}
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.