0

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?

AlanT
  • 3,627
  • 20
  • 28
OSH
  • 2,847
  • 3
  • 25
  • 46
  • `wregex` is itself a typedef. You need `basic_regex`. – Kerrek SB Nov 23 '11 at 19:43
  • I followed the def but got stuck on the regex traits: `typedef basic_regex > wregex;` ... `template struct regex_traits : public implementationT { regex_traits() : implementationT() {} };` but where can I specify the allocator? – OSH Nov 23 '11 at 19:47
  • According to this (a bit old) thread [http://lists.boost.org/Archives/boost/2009/12/159575.php], you can't, at least not without manually adding a template parameter and changing the source coude. – jrok Nov 23 '11 at 19:53

0 Answers0