std::predicate(3)

πŸ“¦
version 2024.07.05 Β· 3 versions
, in nixpkgs unstable, opensuse-leap 16.0

okay bestie, welcome to the std::predicate(3) page from the C++ Standard Libary (yes, that's the header spelling, love that for us) β€” the manual name is right there at the top, no cap. Let's get into the vibe check. πŸ’–βœ¨

πŸŽ€ NAME πŸŽ€

  • std::predicate - std::predicate (literally the name and the one-liner, iconic).

✨ Synopsis ✨

Defined in header <concepts>.

template< class F, class... Args >

concept predicate =                                      (since
C++20)
       std::regular_invocable<F, Args...> &&

       boolean-testable<std::invoke_result_t<F, Args...>>;

That (since C++20) annotation means this concept is since C++20, slay. 🫢

So the concept std::predicate<F, Args...> specifies that F is a predicate that accepts arguments whose types and value categories are encoded by Args... β€” i.e., it can be invoked with these arguments to produce a boolean-testable result. That's the whole main character energy of this page. πŸ’…

Important note, bestie: regular_invocable requires the invocation to not modify either the callable object or the arguments and be equality-preserving. No sneaky mutations, fr fr. πŸ™ˆ

🌈 Equality preservation 🌈

Okay so equality preservation: Expressions declared in requires expressions of the standard library concepts are required to be equality-preserving (except where stated otherwise). That's the rule, iykyk. πŸ¦‹


This gem came from cppreference.com, version 2024.06.10, and it's the std::predicate(3) page β€” mwah, bye bestie! πŸ’‹πŸŒΈ

πŸ“¦ where this page comes from