Link to home
Start Free TrialLog in
Avatar of Unimatrix_001
Unimatrix_001Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Specifying default allocator

Hello.

If I have something like vector<int>, there is a default allocator given, I know that uses new(), but say I'm creating a new container class, how can I specify to use the default allocator as the STL container classes do?

template<typename TAllocator=???>

Thanks,
Uni
Avatar of evilrix
evilrix
Flag of United Kingdom of Great Britain and Northern Ireland image

typedef vector<int, MyAllocator> MyVecType;
Sorry.. mis read... I'll try again...
struct MyAllocator // Must model an allocator concept
{
};

template < typename T, typename aT = MyAllocator>
struct MyVector
{
};
Avatar of Unimatrix_001

ASKER

But how about if I'm wanting the default allocator provided by the STL - i.e. vector<int> uses new(). How do I go about doing that?
ASKER CERTIFIED SOLUTION
Avatar of evilrix
evilrix
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ah thank you. :)