Header lexy/callback/noop.hpp

Callback and sink lexy::noop

lexy/callback/noop.hpp
namespace lexy
{
    constexpr callback auto noop;
    constexpr sink<>   auto noop;
}

A callback and sink that ignores all arguments and returns void.

As a callback, it can be called with arbitrary arguments that are all ignored. As a sink, the sink callback also ignores all arguments.

Example 1. Ignore all errors produced during parsing
int main()
{
    auto input = lexy_ext::compiler_explorer_input();

    // Parse the production, but ignore all errors.
    auto result = lexy::parse<production>(input, lexy::noop);
    if (!result)
        // Note that parsing can still fail.
        return 1;

    std::printf("The value is: %d\n", result.value());
}