Negators(3)

πŸ“¦ version 4.4.0, in nixpkgs unstable

okay so bestie, this is Negators(3) from the Library Functions Manual β€” and the NAME is literally Negators. That's the whole name, no cap. It's the little libstdc++ page about negation functors, and we're gonna get into it πŸ’….

πŸ’– NAME πŸ’–

Negators β€” that's the name, bestie. The page is called Negators(3), from the Library Functions Manual, and it's giving classic negation-functor energy.

πŸŽ€ Classes

  • class std::binary_negate< _Predicate > β€” one of the negation functors. yep, that's the whole description, and we're keeping it.
  • class std::unary_negate< _Predicate > β€” one of the negation functors. iconic.

✨ Functions

  • template<typename _Predicate > unary_negate< _Predicate > std::not1 (const _Predicate &__pred) β€” the not1 function template, right here.
  • template<typename _Predicate > binary_negate< _Predicate > std::not2 (const _Predicate &__pred) β€” the not2 function template, right here.

🌸 Detailed Description 🌸

okay so the functions not1 and not2 each take a predicate functor and return an instance of unary_negate or binary_negate, respectively. That's the whole glow-up. These classes are functors whose operator() performs the stored predicate function and then returns the negation of the result. So it does the thing, then flips the boolean. periodt.

For example, given a vector of integers and a trivial predicate, you get this iconic little setup:

         struct IntGreaterThanThree
           : public std::unary_function<int, bool>
         {
             bool operator() (int x) { return x > 3; }
         };

         std::find_if (v.begin(), v.end(), not1(IntGreaterThanThree()));

The call to find_if will locate the first index (i) of v for which '!(v[i] > 3)' is true. That's the vibe: it finds the first one that is not greater than three. no cap.

The not1/unary_negate combination works on predicates taking a single argument. The not2/binary_negate combination works on predicates which take two arguments. simple as that, bestie πŸ¦‹.

πŸ”₯ Function Documentation πŸ”₯

🌟 template<typename _Predicate > unary_negate<_Predicate> std::not1 (const _Predicate & __pred) [inline]

One of the negation functors.

Definition at line 364 of file stl_function.h.

🌟 template<typename _Predicate > binary_negate<_Predicate> std::not2 (const _Predicate & __pred) [inline]

One of the negation functors.

Definition at line 389 of file stl_function.h.

πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for libstdc++ from the source code. so not a human author, just Doxygen doing its little automated thing πŸ’….


okay bestie, that's the whole manual page! it's libstdc++, dated 21 Apr 2009, and the page is Negators(3) β€” mwah, slay, bye πŸ’–βœ¨

πŸ“¦ where this page comes from