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
LVL 3
Unimatrix_001Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

evilrixSenior Software Engineer (Avast)Commented:
typedef vector<int, MyAllocator> MyVecType;
0
evilrixSenior Software Engineer (Avast)Commented:
Sorry.. mis read... I'll try again...
0
evilrixSenior Software Engineer (Avast)Commented:
struct MyAllocator // Must model an allocator concept
{
};

template < typename T, typename aT = MyAllocator>
struct MyVector
{
};
0
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Unimatrix_001Author Commented:
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?
0
evilrixSenior Software Engineer (Avast)Commented:
>> vector<int> uses new()
No, vector uses std::allocator

std::vector<T, std::allocator<T> >

template < typename T, typename aT = std::allocator<T> >
struct MyVector
{
};
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Unimatrix_001Author Commented:
Ah thank you. :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.