How is C++ STL list implemented internally

The previous article in this series called STLHow, showed how to implement STL Vector. This article will go into details about implementation of STL list. Implementing STL List The node The STL list requires traversal in both the directions by means of forward and reverse iterator. Hence the list should be implemented as a doubly linked list. The node of the list is defined as below.

 List class

The list maintains pointers to […]

C++ auto_ptr for pointer to array

An auto_ptr can wrap a raw pointer but this raw pointer should not be a pointer to an array because auto_ptr will not release memory of the array when it goes out of scope. auto_ptr calls delete on the pointer when it goes out of scope. However for memory pointed to by an array pointer is to be freed then delete[] needs to be called and not delete. How can you have an auto_ptr for […]

How is C++ STL vector implemented internally

There are many open source implementations of STL. However it is difficult to read the STL code because it is meant to be practically usable than readable. STLHow is an implementation of C++ Standard Template Library (STL) written in easy to understand and human readable code. A series of articles here on codefreakr will discuss the STLHow to demonstrate “How the STL is implemented”. Implementing STL Vector Constructors and Destructor Vector is implemented as a […]