问题
I created a custom allocator and want to use it all across our code. The way we did it is by defining the templates that wrap each containers we use and make use of our own allocator instead of the default:
template <class Type>
class myVector : public std::vector<Type, CCustomAllocator<Type>>
and so we can use it in our code like this:myVector<int> x
. This reduces the chance of making mistakes.
we have similar wrappers for all the containers we use in our code: list
, string
, wstring
, ...
I hope this approach makes sense.
I am having trouble defining this type of template wrapper for boost::wregex
. Can regex use a specified allocator?
来源:https://stackoverflow.com/questions/8248076/using-custom-allocator-for-boostwregex