As pointed out by this post, in 'Modern C++ Design - Generic Programming and Design Patterns Applied', Andrei Alexandrescu uses classes with template template parameters to implement the policy pattern:
// Library code
template <template <class> class CreationPolicy>
class WidgetManager : public CreationPolicy<Widget>
{
...
};
Now, suppose that the policy class has a state (i.e. it has non-static members) and that the host class stores an object of the policy class:
// Library code
template <template <class> class Logger>
struct Algorithm
{
Algorithm(Logger<Event> &logger) : logger_(logger) {}
...
private:
Logger<Event> &logger_;
};
The user will probably write something like this:
using MyLogger = ConcreteLogger<MyEvent>;
MyLogger log;
Algorithm<ConcreteLogger> alg(log);
Since the user needs to instantiate ConcreteLogger
, is there any remaining advantage in using template template parameter in this case?