allocator

Allocator specialized for array types in c++14?

谁都会走 提交于 2021-02-08 01:26:41
问题 Why isn't there an array template specialization for std::allocator<T[]> in c++14? When playing around trying to specialize std::allocator<T[]> myself I hit a dead-end when implementing the construct() and destroy() method. Is this the reason? Why then have construct() and destroy() part of std::allocator<>? template <T> class allocator <T[]> { // ...most is similar for std::allocator<>... template <class U, class... Args> void construct( U *p, Args&&.. args) { // what to write for array

Allocator specialized for array types in c++14?

那年仲夏 提交于 2021-02-08 01:24:22
问题 Why isn't there an array template specialization for std::allocator<T[]> in c++14? When playing around trying to specialize std::allocator<T[]> myself I hit a dead-end when implementing the construct() and destroy() method. Is this the reason? Why then have construct() and destroy() part of std::allocator<>? template <T> class allocator <T[]> { // ...most is similar for std::allocator<>... template <class U, class... Args> void construct( U *p, Args&&.. args) { // what to write for array

Allocator specialized for array types in c++14?

落爺英雄遲暮 提交于 2021-02-08 01:23:08
问题 Why isn't there an array template specialization for std::allocator<T[]> in c++14? When playing around trying to specialize std::allocator<T[]> myself I hit a dead-end when implementing the construct() and destroy() method. Is this the reason? Why then have construct() and destroy() part of std::allocator<>? template <T> class allocator <T[]> { // ...most is similar for std::allocator<>... template <class U, class... Args> void construct( U *p, Args&&.. args) { // what to write for array

Allocator specialized for array types in c++14?

孤人 提交于 2021-02-08 01:22:35
问题 Why isn't there an array template specialization for std::allocator<T[]> in c++14? When playing around trying to specialize std::allocator<T[]> myself I hit a dead-end when implementing the construct() and destroy() method. Is this the reason? Why then have construct() and destroy() part of std::allocator<>? template <T> class allocator <T[]> { // ...most is similar for std::allocator<>... template <class U, class... Args> void construct( U *p, Args&&.. args) { // what to write for array

C++: Can't propagate polymorphic_allocator with scoped_allocator_adaptor

荒凉一梦 提交于 2021-01-27 05:24:39
问题 I have a vector<vector<int>> and want the entire memory (i.e., of both the outer and the inner vector) to be taken from a memory_resource . Here is a stripped down example, first the boring part: #include <boost/container/pmr/memory_resource.hpp> #include <boost/container/scoped_allocator.hpp> #include <boost/container/pmr/polymorphic_allocator.hpp> #include <iostream> #include <string> #include <vector> // Sample memory resource that prints debug information class MemoryResource : public

How to pass an std::vector with custom allocator to a function that expects one with std::allocator?

一世执手 提交于 2020-07-08 09:40:34
问题 I am working with an external library (pcl) so I need a solution that does not change the existing function prototypes. One function that I am using generates an std::vector<int, Eigen::aligned_allocator<int>> . The function that I want to call next expects a const boost::shared_ptr<std::vector<int, std::allocator<int>>> . I do not want to copy the elements because it is in an already slow critical part of my code. If not for the allocator mismatch, I would get around the shared_ptr

Is there something similar to the copy-and-swap idiom when allocators are involved?

本小妞迷上赌 提交于 2020-06-09 11:36:49
问题 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 looks like this: T& T::operator=(T other) { this->swap(other); return *this; } This assignment works for both copy and move assignment because other is copy or move constructed depending on whether the right hand side of the assignment is an lvalue or an rvalue. Now let's have stateful allocators

Is there something similar to the copy-and-swap idiom when allocators are involved?

大兔子大兔子 提交于 2020-06-09 11:35:08
问题 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 looks like this: T& T::operator=(T other) { this->swap(other); return *this; } This assignment works for both copy and move assignment because other is copy or move constructed depending on whether the right hand side of the assignment is an lvalue or an rvalue. Now let's have stateful allocators