Being half-way through Andrei Alexandrescu's book, Modern C++ Design, I am intrigued by his policy-based design. I am sure there are many in this forum who are competent with this design approach.
I am in a situation where I would like to pass the type of the host class as a template parameter to one of the host's policy classes. Is this possible?
Consider the following problem. I have a host class that I would like to overload the new and delete operators. A policy should define the characteristics of the creation and deletion of the object.
template <class Type> class Pool { Type* create() { ... } };
How could I make something like this work? And yes, I realize that the Pool class could just return void*. Let's avoid that solution. I would like to know if there is a general solution to this problem because I believe there are other situations in which it might serve.
template < template <class> CreationPolicy > class Host : public CreationPolicy< Host> { ... }
Because you are dealing with pointers and are not accessing any of the methods of Host within the CreationPolicy then doing so should not be a problem... I could be terribly wrong. Let me know because I am kind of answering this from C++ vacation.