STL algorithm design concept-Function adapter

Source: Internet
Author: User

1) Theoretical knowledge of function adapters





2) Common function function adapter
The standard library provides a set of function adapters that specialize or extend a unary and two-tuple function object. Common adapters are:
1. Binder (Binder): Binders Convert a two-tuple function object to a unary function object by binding an argument to a special value. The C + + standard library provides two predefined binder adapters: bind1st and bind2nd, which bind values to the first argument of a two-tuple function object, which is bound on the second argument.

2. Inversion (negator): Negator is a function adapter that flips the value of a function object. The standard library provides two predefined ngeator adapters: Not1 flips The true value of a unary predefined function object, and Not2 flips the true value of a two-tuple predicate function.
A list of commonly used function adapters is as follows:
bind1st (OP, value)
bind2nd (OP, value)
Not1 (OP)
Not2 (OP)
Mem_fun_ref (OP)
Mem_fun (OP)
Ptr_fun (OP)

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

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.