Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use C++ STL bind1st bind2nd bind

Shulou Source: shulou.com Published: 2022-06-02 06:38:15 10月26日 Update

This article mainly explains "how to use C++ STL bind1st bind2nd bind". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use C++ STL bind1st bind2nd bind.

Description

Bind1st () and bind2nd (), which are already deprecated in Category 11, are recommended to use the new standard bind ().

The following explains the use of bind1st () and bind2nd (), and then explains the use of bind ().

Header file

# include

Action

Both bind1st () and bind2nd () convert a binary function to a unary function by binding one of the parameters.

Bind1st () is the first parameter to bind.

Bind2nd () is the second parameter bound.

Example # include # include # include using namespace std; int main () {int numbers [] = {10 cout 20, 30, 40, 50, 10}; int cx; cx = count_if (numbers, numbers + 6, bind2nd (less (), 40)); cout

Tags: Functions parameters methods usage examples elements content faceted learning convenience practicality deeper intuitive useful interest multiple practical practical suggestions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology macOS Apple Docker Shulou Tech Info