allocator Questions
2
Solved
Assuming alignment is a uintptr_t power of 2, looking for the next properly aligned address can be done using this expression:
(address + alignment - 1u) & ~(alignment - 1u)
This is used in cu...
Earthwork asked 23/10 at 23:36
1
Solved
As shown here, the behavior of allocate(0) is unspecified.
So, what will happen if I call allocate_at_least(0) according to C++23 standard? Is the behavior implementation-defined, or will it be tre...
Amylopsin asked 19/5 at 9:56
1
Solved
The documentation for the std::allocator<T>::allocate member function says in ([allocator.members]) that:
Remarks: The storage for the array is obtained by calling ::operator new ([new.del...
Elephant asked 27/2 at 14:29
5
Solved
This question is about owning pointers, consuming pointers, smart pointers, vectors, and allocators.
I am a little bit lost on my thoughts about code architecture. Furthermore, if this question ha...
Medawar asked 27/5, 2019 at 10:36
4
Solved
According to cppref:
std::allocator<T>::allocate_at_least
Allocates count * sizeof(T) bytes of uninitialized storage, where
count is an unspecified integer value not less than n, by calling
...
Glidewell asked 8/9, 2021 at 7:1
1
cppreference's example of std::allocator contains this code (shortened for simplicity):
// default allocator for ints
std::allocator<int> alloc1;
using traits_t1 = std::allocator_traits<d...
Horsey asked 1/9, 2023 at 13:33
2
Solved
Does std::vec::shrink_to_fit allocate a new, smaller vec.len() buffer of data, copy to it, and destruct the old buffer, or does it somehow indicate to the memory allocator that the uninitialised pa...
Hagler asked 22/5, 2023 at 17:0
2
Solved
I've recently been fiddling with developing a custom allocator based on a memory pool, that is shared between multiple instances of the allocator.
The intention was that the allocator be compatibl...
Sightread asked 3/12, 2012 at 5:27
1
Solved
In his talk "Solving the Right Problems for Engine Developers", Mike Acton says that
the vast majority of the time, all you're going to need are these three types of allocator: there's t...
Unionize asked 29/12, 2022 at 20:59
2
Solved
The default std::allocator class is stateless in C++. This means any instance of an std::allocator can deallocate memory allocated by another std::allocator instance. What is then the point of havi...
2
Solved
There were a couple of great answers about the copy-and-swap idiom, e.g., explaining the copy and swap idiom and explaining move semantics. The basic idiom working for both copy and move assignment...
1
Solved
Standard allocators can optionally take a hint as a second parameter https://en.cppreference.com/w/cpp/memory/allocator/allocate
T* allocate( std::size_t n, const void * hint);
Leaving aside that ...
2
I am attempting to implement an Allocator which allows me to use a 'fancy' pointer along the lines of boost::interprocess::offset_ptr with STL types.
As a self contained template the pointer itself...
Gabrielgabriela asked 24/5, 2022 at 1:58
8
Solved
If I want to process data in a std::vector with SSE, I need 16 byte alignment. How can I achieve that? Do I need to write my own allocator? Or does the default allocator already align to 16 byte bo...
Peal asked 10/12, 2011 at 11:38
1
Solved
I am struggling with the performance of my custom allocator.
My question is regarding a debug build.
normally I don't mind if there is only a bit of a drop. but currently I am playing something in ...
4
I'm using a custom allocator to account for memory usage in several containers. Currently I use a static variable to account for the memory usage. How could I separate this account across several c...
Collarbone asked 27/10, 2009 at 9:22
4
Solved
Is it possible to make std::vector of custom structs allocate aligned memory for further processing with SIMD instructions? If it is possible to do with Allocator, does anyone happen to have such a...
Intertwist asked 17/10, 2012 at 20:9
2
Solved
I am currently working on programming a pool allocator. My question boils down to the following code:
template <typename T>
union myUnion {
T data;
myUnion<T>* nextUnion;
};
void som...
Trilley asked 2/5, 2017 at 21:24
1
Autogenerated ROS (Robot Operating System) message C++ header files contain typedefs like this:
typedef ::std_msgs::Header_<std::allocator<void> > Header;
What does std::allocator<v...
1
Solved
Suppose I have a custom stateful allocator that I want to use for a STL container. The container is going to use the rebind_alloc trait to allocate its internal elements, thus by default (or by def...
1
Solved
Is it possible to specialize the std::allocator_traits, template like this?
namespace falloc_ {
template<class Tp> class FAllocator ;
}
// partial spec for all falloc_::FAllocator<U>...
Obtect asked 2/3, 2021 at 22:5
2
Solved
I'm trying to implement my own allocator, which should work with STL containers and use a custom fancy pointer implementation.
I'm pretty sure, that my classes fulfill all requirements (according t...
Marciano asked 9/1, 2021 at 18:5
2
Solved
C++20 removed the construct() and destruct() members from std::allocator. How am I supposed to construct my objects allocated through std::allocator<T>::allocate()? I found std::uninitialized...
2
I'd like to use a std::pmr::unordered_map with a std::pmr::monotonic_buffer_resource. The two fit well together, because the set's nodes are stable, so I don't create a lot of holes in the buffer r...
Tresa asked 17/11, 2020 at 14:22
2
Solved
Here are the key points:
1: This project uses the open-source repository NanoRT as a raytracer in a project.
2: This project is compiled under Visual Studio 2019 (C++17)
3: This project is compiled...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.