c++ metacall()()()™

What is happening here ?

Contents

Compiler dispatches all the calls from the main() examples, above to the particular “metacall” instance,  Each of them calls, is passed to the current processor, passed as template argument.  ::dbj::meta_call::default_processor is just the default one of the (potentially) many processors functors available.

Remember the first argument. It’s type decides what will be done with a paraticular  call, in the stream of calls.

This is how default processor behaves. It simply calls the first argument with the remaining arguments , if it is found to be invocable, that is. This is how the bridge between metacall mechanism and user defined types is established.

By default or by using user defined processor.

If it is not callable and there is no processor for a type of the first argument arrived into it, that call is by default simply logged.  The safe assumption is here, the user has already delivered a processor for dealing with that type. For an example see the user defind proceesor bellow which deals with booleans.

The term “bridge” sometimes used, by me, in this context means an “bridge” to the implementation. I am also using the term “bridge” because this implementation hiding concept, reminds me (somewhat) on the “bridge pattern” as described by Gof4.

Actual class diagram of metacall and the user processor (in this online project) is this:

metacall + user

Which processor/bridge functor is going to be used is decided by the users at compile time. It’s type is a template argument. Let us repeat the usage of this composition mechanism, from the main() above:

Here, user whose code is in the namespace user , has also provided her extension of the default processor. Here is its interface (yes, the actual code is in that project on line)

Thus in the main() where user has decided to use her own processor:

And now cst is completely interchangeable with the default metacall with the added benefit of user defined bool calls processing.

What we have till now is enough to use this modern c++ call-stream implementation. And enjoy its default behaviour.