STL algorithm design concept-Function adapter

Source: Internet
Author: User

1) Theoretical knowledge of function adapters





2) Frequent use of function function adapters
The standard library provides a set of function adapters that specialize or extend a unary and two-tuple function object. Frequently used adapters are:
1. Binder (Binder): Binders bind a two-tuple function object to a particular value. Convert it to a unary function object.

The C + + standard library provides two pre-defined binder adapters: bind1st and bind2nd. The former binds the value to the first argument of a two-tuple function object, and the latter is bound to the second actual participation.



2. Inversion (negator): Negator is a function adapter that flips the value of a function object. The standard library provides two pre-defined Ngeator adapters: NOT1 flips a dollar in advance to define the true value of the function object, while Not2 flips the truth value of the two-tuple predicate function.
Use the list of function adapters frequently such as the following:
bind1st (OP, value)
bind2nd (OP, value)
Not1 (OP)
Not2 (OP)
Mem_fun_ref (OP)
Mem_fun (OP)
Ptr_fun (OP)

STL algorithm design concept-Function adapter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.