The code generated by the compiler looks like this:
Although the Tag1 and Tag2 are empty classes, the compiler still uses integer value 0 as a first parameter to the function.
Let's try to optimise this redundant mov r0, #0 instruction away by making it visible to the compiler that the tag parameter is not used:
Somewhere in the main function:
The code generated by the compiler looks like this:
In this case the compiler optimises away the tag parameter.
Based on the above we may make a CONCLUSION: When tag dispatching idiom is used, the function that receives a dummy (tag) parameter should be a simple inline wrapper around other function that implements the required functionality. In this case the compiler will optimise away the creation of tag object and will call the wrapped function directly.