G
Gary Nastrasio
I'm currently reading Andrei Alexandrescu's book "Modern C++ Design" and
I'm a bit confused by one bit of template syntax in chapter 1.
Here is a code example:
template <class CreationPolicy>
class WidgetManager : public Creation Policy {...}
// Create an instance of WidgetManager which managers type Widget
WidgetManager< OpNewCreator<Widget> > MyWidgetMgr;
Basically the above creates a WidgetManager that handles creating new
Widgets - I completely understand this code. Since it's obvious a
WidgetManager will create type Widget, he says this code is better:
template <template <class> class CreationPolicy>
class WidgetManager : public CreationPolicy<Widget> {...}
// Create an instance of WidgetManager which managers type Widget
WidgetManager<OpNewCreator> MyWidgetMgr;
I'm very confused by the line "template <template <class> class
CreationPolicy>". What exactly is going on in here?
Thanks!
I'm a bit confused by one bit of template syntax in chapter 1.
Here is a code example:
template <class CreationPolicy>
class WidgetManager : public Creation Policy {...}
// Create an instance of WidgetManager which managers type Widget
WidgetManager< OpNewCreator<Widget> > MyWidgetMgr;
Basically the above creates a WidgetManager that handles creating new
Widgets - I completely understand this code. Since it's obvious a
WidgetManager will create type Widget, he says this code is better:
template <template <class> class CreationPolicy>
class WidgetManager : public CreationPolicy<Widget> {...}
// Create an instance of WidgetManager which managers type Widget
WidgetManager<OpNewCreator> MyWidgetMgr;
I'm very confused by the line "template <template <class> class
CreationPolicy>". What exactly is going on in here?
Thanks!