C++ :: Use TBB Scalable And STL Allocator Together

May 22, 2014

I have a matrix class who use the stl vector to manage its

memory(UInt is typedef of size_t):
class Mtrx {
protected:

[Code]....

However, the two different classes are only different with each other on the allocator. I am thinking, that a elegant way should be merging them together.

View 1 Replies


ADVERTISEMENT

C++ :: How To Build A Custom Allocator

Feb 7, 2014

I'm trying to write a custom allocator that I can use with the STL. Here's what I have so far :

Code:
#include <cstddef>
#include <iostream>
#include <memory>
#include <vector>
template<class T>
struct customallocator {

[Code].....

I'm doing and currently, my push_back doesn't seem to do anything.

View 12 Replies View Related

C++ :: Relation Between A Container And Allocator

Mar 30, 2014

To my understanding, a Container should have an Allocator member data, which is used internally.

Question: what happens, for example, when we swap() two containers that use different allocators?

Must the allocators be swapped as well?

Must all elements of the container be reallocated when the allocator is changed?

View 7 Replies View Related

C++ :: Relation Between Allocator And NodeAllocator In A Container?

Mar 31, 2014

Consider a singly-linked list container.

Being constructed with an alloc<T>, it will rebind it as alloc<node<T>> for internal use.

Question: is allocator_type the same as alloc<T> or as alloc<node<T>>?

View 2 Replies View Related

C++ :: Rebinding Allocator For The Nodes Of Linked List?

Mar 27, 2014

I am coding a singly-linked list container. Of course, internally it uses Node<T>.

Question: what is the correct way to use the allocator given by the user? I ask, because I've read this on the rival C++ Reference:

std::list<T, A> allocates nodes of some internal type Node<T>, using the allocator std::allocator_traits<A>::rebind_alloc<Node<T>>, which is implemented in terms of A::rebind<Node<T>>::other if A is an std::allocator

[URL]...

The above doesn't seem right to do, because then what should pointer and const_pointer be?

using pointer = std::allocator_traits<Alloc>::pointer;
using const_pointer = std::allocator_traits<Alloc>::const_pointer;
// but we're using Alloc<Node<T>> not Alloc<T>
// so maybe do this?
using pointer = value_type *;
using const_pointer = const value_type *;

View 6 Replies View Related

C++ :: Custom Dynamic Array Class And Allocator

May 10, 2014

I attempted to create a dynamic array class for use in my engine (due to problems regarding a dll-interface with the standard library), so I tried at making a standard-compatible allocator template class first. After I "finished" that, I went on to work on the dynamic array class itself.So I finish the dynamic array class, and test it with the standard allocator. It works perfectly, but when I test it with my custom allocator class, it fails terribly.

To make sure it wasn't my DynamicArray class that was causing issues, I tried using the custom allocator on the std::vector class template, and it didn't work either. IMy DynamicArray class code:

// Represents a dynamic array, similar to the standard library's "vector" class.
template<typename T, typename A>
class DynamicArray
{
public:
DynamicArray() :
data(nullptr),
elements(0),
capacity(0)

[code].....

The "Request" and "Free" functions are my engine's equivalent of malloc and free (or new and delete). I allocate a large buffer (16 mb), and through those functions I distribute the memory to where it's needed.

View 9 Replies View Related

C++ :: Writing Custom Allocator - Throws Exception

Mar 4, 2012

Does the requirements have changed for writing custom allocators with C++ 0x11?

A custom allocator (that uses a fixed array as its memory pool) that I have been using successfully for some time, now throws an exception!

It runs fine under VS2008 but bombs out with VS2010.

View 14 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved