Status & Roadmap
Authors & License
Funding U++
Search on this site

SourceForge.net Logo

SourceForge.net Logo

GitHub Logo

Discord Logo

NTL - STL Comparison

NTL was created to solve following problems we used to encounter when using STL:

Copy-constructible requirements

STL requires the elements stored in containers to meet the requirements of copy-constructible and assignable types. This causes two problems:

Elements that do not satisfy these requirements cannot be directly stored in STL containers.

For many types of elements, including STL containers themselves, copy-constructor and assign operator is a very expensive operation, that is why often they cannot be stored in STL containers effectively.

NTL addresses this problem by introducing Vector and Array flavors of containers.

Value transfer

STL provides deep copy of containers as default operation for (most) '=' cases, with && based move semantics for specific or explicit cases (std::move). NTL requires to specify the mode of transfer with 'pick' (corresponds to std::move) or 'clone' functions in all cases, except the assignment of temporary value (where the final semantics is the same).

Random access and random access notation

STL uses iterators as the preferred way how to access and identify elements in containers. While this is generally the most generic way, real-life problems often require or at least benefit from random access using indices. NTL provides fast random access to all kinds of containers and NTL interfaces prefer notation using indices. As a side effect, NTL user can completely avoid using iterators in favor of indices, which in current C++ results in much simpler and less verbose syntax (using modern optimizing compilers there is no difference in performance).


A completely new type of associative container, Index, is introduced, as an ideal building block for all kinds of associative operations.

InVector, Sorted maps

NTL provides random access containers with fast insertion at arbitrary position, which scale well to milions of items. These containers then provide basis for 'sorted maps' that are using binary search.

Algorithm requirements

Requirements of STL algorithms are very loosely defined. NTL tries to provide more specific requirements and also minimal ones. This allows e.g. direct sorting of Array of polymorphic elements.

Minor improvements

There are also some minor improvements:

Besides reserve present in STL, NTL provides also Shrink method to minimize a container's memory consumption.

Do you want to contribute?