Click here to Skip to main content
15,031,495 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good day to everybody.
I need to create the STD::MAP structure for a specified number of elements without dynamic memory allocation. Just at the moment of creation MAP allocate memory and after that didn't work with memory.

Already read about allocator, but couldn't use it.

On some sites read that it's doesn't work with MAP, only with Vector and other, but found that is implemented in the class "fast_pool_allocator".

Please help =)
Updated 3-Apr-12 20:44pm

If you know the maximum number of element in your map, then you can tweak your allocator to pick memory from stack,, no dynamic allocation but you be careful with stack limits (this map should not be shared between threads.)
If these are your requirements the reply for more specific answer.
Devdits 4-Apr-12 4:12am
Please, Can you write simple example of it?
I think it is possible only with boost libraries.[^]
I am not sure about its license. Please go through the site.
uisng boost::assign name space it is possible as below

map<int,int> next = map_list_of(1,2)(2,3);

hope this is what you were looking for
Devdits 4-Apr-12 4:18am
unfortunately, no =(
I only know the maximum count of items, but I don't know values of them.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900