Quote:
One way is the Template pattern, but that uses a polymorphic call to my (protected) implementation function.
This is true. You have explicitly stated you want polymorphism. The template method (the actual class method you invoke in the example code) is polymorphic. Where is the problem? Do you mean virtual method call?
Quote:
I want to use a static interface using the Barton-Nackman trick.
No. You don't. Building interfaces using templates instead of inheritance for polymorphism is a fine thing, if you understand the consequences, but that has nothing to do with the "BN Trick".
The "BN Trick" is a tool used to provide a certain interface based on functionality defined elsewhere at a target scope without having to code the specific interface for every implementation. It is not the interface itself.
If you dropped the ridiculous attempt at the "BN Trick" and simply wrote your algorithms to a set of interfaces the generic mechanism of templates would use the interfaces related to the types involved. That is what templates do; that is their purpose.
Quote:
Do I not escape from a heterogenous container with "boost::any" ?
Considering the way `boost::any' works, you aren't going to gain anything by what you envision. You'll still have to build your entire system around generics to get the polymorphism you seek. Also, in using `boost::any' you would be using a virtual method call.
Quote:
is this the BN trick? or is this already a crtp.. i have the impression that a crtp is merely the use of the BN trick in template expressions
O_o
What?
I don't know what you've been reading, but the "BN Trick" relies on "CRTP" for implementation.
You can not have the "BN Trick" without "CRTP".
You can use "CRTP" for a lot of things, but "CRTP" is not the "BN Trick".
Soma