C ++ statically allocated implementation with double ended queue

STL has a deque implementation ; Boost has a deque implementation ; But both of them use the STL path of the sequence containers (dynamic allocation using dispensers).

I am looking for a reliable, fast and statically dedicated deque implementation. Which looks something like this:

template<typename T, unsigned int S>
class StaticDeque
{
   T m_elements[S];
};

So, all the elements that need to be assigned statically.

Note 1: I already have a solution based on STL (using custom allocators that statically distribute data for the vector and deck), but I'm looking for any better solution (shorter runtime).

Note2: I need statically distributed memory, because I process data in a predefined shortcut in memory. Thus, the object will be declared as follows:#pragma DATA_SECTION("fast_memory") StaticDeque<int, 10> payloads;

+5
source share
1 answer

You can use the Howard Hinnant stack allocator , which reuses an existing implementation std::dequewith a modified allocator . You can provide any part of the memory to the dispenser constructor, including the so-called arena object, which contains an array of characters on the stack. You can also use the arena object that contains the statically allocated portion of the memory on the heap by slightly modifying the arena class.

, 100% , , , , , ::operator new . , ++ 14 . std::deque ( ).

, STL, , .

+2

All Articles