allocator Questions

3

Solved

As far as I can tell, the requirements on an allocator to be used with STL containers are laid out in Table 28 of section 17.6.3.5 of the C++11 standard. I'm a bit confused about the interaction b...
Cyanine asked 18/6, 2014 at 6:50

1

I want to create unordered_map(Because I specifically want a hash map). I want to allocate its max size (according to my constraints) in the beginning. So, if I want to allocated 256 entries, and t...
Catchfly asked 8/3, 2015 at 9:52

2

Solved

I am trying to use std::unique_ptr<T[]> with custom memory allocators. Basically, I have custom allocators that are subclasses of IAllocator, which provides the following methods: void* Allo...
Private asked 9/2, 2015 at 15:17

2

Suppose you have a Container which internally uses other standard containers to form more complex data structures. Thankfully, the standard containers are already designed to do all the necessary w...
Coppage asked 15/12, 2014 at 23:18

1

Solved

The C++11 std::allocator_traits template is used to query an Allocator to determine whether propagate_on_copy_assignment and propagate_on_move_assignment is true. These values affect how Container ...
Fax asked 15/12, 2014 at 20:27

1

Solved

I'm trying to understand how to properly write AllocatorAware containers. My understandings is that the propagate_on_container_move_assignment typedef indicates whether or not a certain Allocator ...
Metropolitan asked 14/12, 2014 at 15:56

4

Solved

When using STL containers, I am not sure whether an int allocated by the default allocator has been zeroized. The following code indicates 'yes' to the question: #include <map> #include <...
Mythomania asked 6/3, 2012 at 13:30

7

Solved

In a project about a decade ago, we found that std::vector's dynamic allocations caused a serious performance drain. In this case it was many small vectors allocated, so the quick solution was to w...
Chil asked 14/10, 2014 at 8:47

1

Solved

All the allocator-aware class templates in the STL have to be instantiated with an allocator type. Wouldn't it be a lot more convenient for users if the allocator wasn't a template argument but a t...
Nashville asked 29/8, 2014 at 16:20

1

Solved

The question is in the title. Is this allowed for containers, or are the allocator's methods guaranteed to be called even when the object is trivially constructible/destructible? I did try to sear...
Motherinlaw asked 4/8, 2014 at 20:43

3

Solved

BEFORE YOU READ: const_reference is typedef and does not need to be const T& as you can see in std::vector<bool>::const_reference = bool. Please keep that in mind while reading the rest t...
Wayfaring asked 30/7, 2014 at 7:20

1

Solved

How does std::list allocate the nodes in which it keeps the next/prev pointers and the T element it contains? I think that standard allocators can only be used to allocate memory for one type (bec...
Corinthians asked 26/7, 2014 at 19:47

1

Solved

I'm confused about something. Let's say I have an arbitrary C++ allocator -- say, something like this: template<class T> struct my_allocator { template<class Other> struct rebind { t...
Mario asked 17/7, 2014 at 12:20

2

Solved

To save some code lets say I have a custom allocator named MyAlloc which I have successfully used with a std::vector<int> as follows: std::vector<int,MyAlloc<int>> vec; now I w...
Lianneliao asked 13/1, 2014 at 14:45

2

Solved

Note: Originally asked by Matt Mcnabb as a comment on Why can swapping standard library containers be problematic in C++11 (involving allocators)?. The Standard (N3797) says that if progagate_on...
Sodium asked 20/5, 2014 at 11:20

1

Solved

I have a memory interface that separates out acquiring address space from attaching backing store. (Under Linux the pool of address space managed by the interface is mmap'ed MAP_ANONYMOUS and MAP_N...
Leontine asked 6/5, 2014 at 21:38

2

Solved

In my C++11 program, I use shared_ptr<T> for some objects which are actively created and deleted. It so happened that standard allocator with operator new is a bottleneck, so I want to create...
Richellericher asked 18/3, 2014 at 17:55

4

Solved

I have noticed some interesting behavior in Linux with regard to the Memory Usage (RES) reported by top. I have attached the following program which allocates a couple million objects on the heap, ...
Applicant asked 31/12, 2012 at 21:52

1

Solved

I am writing a collection of allocators, with the intention that they're to be used in very high performance environments, so a little bit of restricted usage (mediated by the compiler, not runtime...
Rockingham asked 23/2, 2014 at 22:45

2

Solved

In the C++11 standard we have std::scoped_allocator_adaptor in the dynamic memory management library. What are the most important use cases of this class?
Lexy asked 3/3, 2014 at 13:37

1

Solved

When using an std::allocator, the deallocate function requires a pointer argument, and a size_type argument (std::allocator<>::deallocate(std::allocator<>::pointer p, std::allocator<...
Haslam asked 1/3, 2014 at 11:45

3

Solved

So I was looking at specification of std::vector and noticed that reference typedef changed from Allocator::reference in C++03 to to value_type& in C++11. I was surprised, so I've started looki...
Acea asked 3/5, 2013 at 13:27

1

Solved

I notice that allocator can only allocate objects of type T and reserve blocks of memory of size n * sizeof(T). Linked list nodes inside of the std::list<T> type, however, aren't necessarily ...
Mcclish asked 6/1, 2014 at 1:39

1

Solved

Related to this question on CodeReview, I tried to use std::unordered_map with a custom allocator but apparently this does not work with gcc/clang and libstdc++. The error can be generated from ini...
Pretor asked 20/9, 2013 at 9:34

1

While reading books on C++ and the standard library, I see frequent references to allocators. For example, Nicolai Josuttis's The C++ Standard Library discusses them in detail in the last ch...
Obligation asked 25/7, 2013 at 2:49

© 2022 - 2024 — McMap. All rights reserved.