In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "how to use external closures". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Add an outer (closure) as a link type to create a function compatible with the closure ABI
Passing the address of the UFCS call to the outer (closure) function creates a closure
Member functions can be implicitly converted to external (closure) functions
It is recommended that the outer (closure) be added as the link type, that is
Outer (closure) empty bar (Foo foo); / / can be converted to closure
This link type modifies the function ABI by passing the first parameter in the same way that the context pointer is passed to the closure function. If the first argument of an outer (closure) function is a class or construction reference, it is like a member function of that type (ABI). Each function in the following example has the same ABI:
Class one
{
Null member function (int x float y)
{
}
}
Outer (closure) empty non-member functions (a class of sparting int x float y)
{
}
Construct a structure
{
Null member function (int x float y)
{
}
}
Outer (closure) empty non-member function (ref-construction s _ int _ x _ float _ y)
{
}
Outer (closure) empty non-member function (a structure * s _ focus int x _ float y)
{
}
Using UFCS, you can extract closures from outer (closure) functions, that is,
Outer (closure) empty bar (Foo foo)
{
/ /...
}
Foo foo
Empty closure () dg = & foo.bar
/ / use UFCS to get the "empty closure ()" with the context pointer set to foo
Using UFCS to extract closures, external (closures) functions have the same syntax as member functions, that is, &.
In this way, templates and plug-ins can use them.
It also maintains type safety between the context pointer and the first parameter of the function through a "confirm later" UFCS call to check the type.
For completeness, the member function should be implicitly converted to an outer (closure) function, that is,
Construct Foo structure
{
Empty bar () / /...
}
Class Foo class
{
Empty bar () / /...
}
Construct Foo structure foo structure
Construct Foo class foo class
Outer (closure) function (ref Foo construction foo) fp1=&foo construction .bar
Outer (closure) function (Foo class foo) fp2=&foo class .bar
That's all for "how to use external closures". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.