xtd 0.2.0
Loading...
Searching...
No Matches

◆ cassert() [1/6]

static void xtd::diagnostics::debug::cassert ( bool  condition)
static

Checks for a condition; if the condition is false, displays a message box that shows the call stack.

Parameters
conditionThe conditional expression to evaluate. If the condition is true, a failure message is not sent and the message box is not displayed.
Examples
The following example shows how to use xtd::diagnostics::debug::cassert_ method.
#include <xtd/diagnostics/debug>
#include <xtd/console>
using namespace xtd;
using namespace xtd::diagnostics;
auto main() -> int {
// Uncomment following lines to remove assert dialog
//for (auto listener : debug::listeners())
// if (is<default_trace_listener>(listener))
// as<default_trace_listener>(listener)->assert_ui_enabled(false);
auto index = 0;
console::write_line("Start application");
debug::cassert_(index > 0);
console::write_line("End application");
}
// This code produces the following output :
//
// > If user clicks assert dialog 'Abort' button:
// Start application
//
// > If user clicks assert dialog 'Retry' button:
// Start application
// > Break the debugger on file debug_cassert.cpp line 12.
// > If user choose continue running after break.
// End application
//
// > If user clicks assert dialog 'Ignore' button:
// Start application
// End application
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
The xtd::diagnostics namespace provides classes that allow you to interact with system processes,...
Definition assert_dialog_result.h:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10