I'm working on a small mathematical optimization framework in C++11, and I wonder what's the best way for the user to provide domain-specific logic. I could force her to define classes with hook methods that can be called by the framework, but I'd like to keep it lean and take advantage of the new C++11 facilities whenever I can. So I'm thinking about accepting std::function
objects, possibly instantiated from lambda expressions, as parameters, and call them when needed. The only think I'm wondering about is whether the compiler (in my case gcc, but I'd like to know about Xcode and Visual C++ as well) will be able to take the std::function objects and inline the function definitions, so that they are optimized together with the rest of the code.
PS: from the comments, it looks like the first revision of my question was obscure to most of the users, probably my fault for using an incorrect language. So I have reworded it, I hope someone can understand the concept I'm trying to convey here (and possibly suggest a solution).
PPS: someone suggested to use templates, that is an idea I have thought about, but I'd like to know if there's an alternative. I don't have anything against templates, but I plan to make a template-based version as soon as this one is working because I find it easier to reason in terms of dynamic objects.