In addition, this will require the inline keyword on each wrapper chain, or since this is just a suggestion, can the compiler decide to optimize this without the keyword?
Yes, the compiler may decide to optimize it anyway, and it may also decide not to optimize it, even if you specify the inline (perhaps by creating a warning if the appropriate compiler options are set) - note that this member of the function is defined in class definitions are implicitly marked as inline .
In general, if embedding is possible, the compiler will decide whether to enable or not based on the body of the called function. However, nesting may not be possible at all if the function is a virtual function or if the function definition is not displayed to the compiler.
Provided that the conditions for inlining are met and that the compiler considers this appropriate, there is no technical problem in constructing a chain of function calls.
As a minor note, note that the functions in your classes must be public , otherwise they will not be available to your wrappers.
source share