Search code examples
c++assertnegationpreconditions

Usage assert(not <condition>)


Reference: std::is_sorted

In the example section of the above link, I see the following usage:

    int data[] = {3, 1, 4, 1, 5};
    assert(not std::is_sorted(std::begin(data), std::end(data)));

I am familiar with the syntax assert(! <condition>)

Evidently, assert(not <condition>) is similar, but wanted to know whether it has been documented somewhere in the standard?

TIA

Vin


Solution

  • The words "and", "or", and "not" are acceptable alternatives for the "&&", "||" and "!" operators in C++.

    https://en.cppreference.com/w/cpp/language/operator_alternative