How to use C++ Expects operator?

Apart from GSL, Excepts exists also in C++20 not in C++17 with a little different syntax

  • https://en.cppreference.com/w/cpp/language/attributes/contract

Expects is part of the GSL library. You have to use some GSL library implementation, which you can find on Github:

  • https://github.com/martinmoene/gsl-lite
  • https://github.com/Microsoft/GSL

These are the ones I have off the top of my head.

The CPP Guidelines likely allude to the "contracts" proposal which provides the same checks via attributes. It was scheduled for C++20, but later removed for lack of consensus on its scope. See p1823r0 and a standard committee member's Reddit thread on the rationale leading to the removal.