Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the application method of bind function in the standard library of Clipper 11?

Shulou Source: shulou.com Published: 2022-06-02 06:55:10 09月25日 Update

This article mainly explains "what is the application method of the bind function of the standard library of Category 11". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. please follow the editor's train of thought to study and learn "what is the application method of the bind function of the standard library of Craft 11".

What is bind?

Bind as its name implies: bind

In popular terms, it can be understood in this way that it is a bit like a function pointer.

The data goes like this: think of the bind function as an adapter for a general-purpose function that accepts a callable object and generates a new callable object to "adapt" to the original object parameter list

It is generally called in the form:

/ / where newCallable is a callable object, and arg_list is a comma-separated list of parameters / / when we call newCallable,newCallable, we call callable and pass the parameter auto newCallable = bind (callable, arg_list) with arg_list.

Okay, the point is in arg_list, so how do we pass in parameters?

They are identified by the position of these parameters, such as _ n, n is shaping, _ 1 is the first parameter, _ 2 is the second parameter, and so on.

The name _ n is defined in the placeholders namespace, while the placeholders itself is defined in the std namespace, so it looks like:

Using std:: placeholders::_1

Next, let's give some examples.

Take a chestnut.

Bind is in the header file # include, which should be included first.

1. Bind ordinary function with no arguments # include # include / / contains this header file / / ordinary function void Fun () {std::cout

Tags: Functions parameters normal files results applications objects methods standards adjustable learning location content multiple space chestnuts adaptation popular as the name implies and so on Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei MariaDB Microsoft NVidia Shulou Information