[#MRDOCS_CHECK_OR_CONTINUE] = MRDOCS_CHECK_OR_CONTINUE :mrdocs: Check a value and skip to the next loop iteration if it failed. == Synopsis Declared in `<mrdocs/Support/Error/Expected.hpp>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- #define MRDOCS_CHECK_OR_CONTINUE(var) ---- == Description If the value failed, the macro runs `continue`. See `MRDOCS_TRY` for what counts as failed. [,cpp] ---- // Node is the struct from the MRDOCS_CHECK_OR example. int total = 0; for (Node const* node : nodes) { MRDOCS_CHECK_OR_CONTINUE(node); // skip null pointers MRDOCS_CHECK_OR_CONTINUE(node->name); // skip empty names MRDOCS_CHECK_OR_CONTINUE(node->n > 0); // skip non-positive counts total += node->n; } ---- The loop expands to roughly this (simplified: the real code calls `::mrdocs::detail::failed`): [,cpp] ---- int total = 0; for (Node const* node : nodes) { // MRDOCS_CHECK_OR_CONTINUE(node); if (failed(node)) { // !node, since node is a pointer continue; } // MRDOCS_CHECK_OR_CONTINUE(node->name); if (failed(node->name)) { // node->name.empty(), a string continue; } // MRDOCS_CHECK_OR_CONTINUE(node->n > 0); if (failed(node->n > 0)) { // the condition is false continue; } total += node->n; } ---- The value is evaluated once, so a call expression like `MRDOCS_CHECK_OR_CONTINUE(isVisible(node))` is fine. Things to keep in mind: * Use it only inside a loop, and end it with a semicolon. * The expansion is two statements. Put braces around it when it's the body of an `if` or `else`. == Parameters [cols="1,4"] |=== | Name| Description | *var* | The value to check. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#