1) We have a legacy C library that is indispensable in a project. The code content of this library is not to be modified, but the library offers the ability to register callbacks that are preferably coded in C++ by the developer utilizing the library. How can such a callback mechanism be possible to construct, and what is an important detail concerning the C library and the signatures of the registered callback functions? Explain.
2) Similar to the C library in the previous question, a C++ library allows callback functions to be registered for utilization as well. Would you expect the C++ library to make use of the same callback mechanism as suggested in the previous question, or are there better alternatives that the C++ library possibly can offer? Explain.
For the 2nd question, I personally would expect by default that a C++ library will have some support for functors (not necessary std::function, but preferably) and lambdas. So if I capture some variables in a lambda and pass it as a callback I'll be sure that the captured objects will be destroyed correctly.
Pavel
Eturnus
Alex
Maide
lbxbcx129
Dima
Jaaa
ברני
Ameer El-Areer
Boris
yue
olli