Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report