Hi,
In my new project i am building a data management module.I want to give a simple template storage type to upper layers like
template<typename T>
class Data
{
public:
T getValue();
private:
boost::numeric::ublas::matrix<T> data;
}
My aim is, to change allocator of data with some different allocators like Boost.inter process allocator or Boost.pool allocator (Boost Ublas Matrix and vector classes takes allocator as a template parameter ).And give only a single class and Factory method to create appropriate allocator under cover.A virtual base class could be sweet but i couldn't handle how to use it with templates.What kind of design patterns or solutions do you offer?
Edit:
I will use boost.pool and boost.shared_memory_allocator.Briefly i want to have different classes with different allocation strategies.But my point is upper parts of program should have no knowledge about it.Real challenge for me is to collect different template classes with an identical base classes.
Edit: For one who want to use matrix class with custom allocator.
it is like this:
using boost::numeric::ublas;
template<typename T, class Allocator = boost::pool_allocator<T>>
class
{
public:
matrix<T, row_major, std::vector<T,Allocator>> mData;
}