uSTL Documentation
0.6
uSTL is a partial implementation of the STL specification intended to reduce code size of the derivative programs. Usually, the STL containers manage their own storage with new[] and delete[] operators, which create strongly typed storage. That is the standard way of allocating C++ object vectors, allowing appropriate constructors and destructors to be called on the allocated storage and ensuring that objects are copied via their copy operators. Although type safety is a good thing, placing memory management code into a template necessitates its reinstantiation for every template instance used by the derivative program. This produces substantial code bloat, that is frequently derided by C developers and used by them as an argument that C is better than C++. The uSTL implementation attempts to work around this problem by factoring memory management code into a non-template base class, ustl::memblock, which performs unstructured memory allocation. STL containers are then implemented as template wrappers for memblock to provide a measure of type safety. The result is that each template instantiation contains less code, and although it does not completely "disappear", due to the requirement for calling placement constructors on the allocated memory, most of it does, being replaced by calls to memblock methods. A vector<T> template instance, for instance, implements virtuals constructBlock (simply a call to placement new[]) and destructBlock (iterates over all elements to manually call the destructor) and two algorithms copy and fill (which most STL programs use anyway); everything else melts away at compile time as if you were using only unstructured storage in the first place. ustl::string is implemented as a static class, not a template, so it is shared among all users of the library. The base classes for unstructured storage management (cmemlink - link to constant memory, memlink - link to mutable memory, and memblock - owner of mutable memory) are, of course, also available for use as data buffers wherever those are needed, and streams that efficiently read and write binary data into them are also available.
The main difference you will notice when using uSTL, is that objects in containers may sometimes undergo bitwise copy. To ensure that this does not harm your objects you need to design them not to contain any pointers to data inside themselves or other objects. I have not encountered any situation when such pointers were needed, but if you have one and do not know how to work around the limitation, I would be happy to give it a try.
You should have received a copy of the configure script with your distribution. Then run configure
with parameters appropriate for your system (usually none). Finally, run make
and make
install
to compile the shared library and install it, along with necessary headers into system-standard directories (see LIBDIR
and INCDIR
in Common.mk for values). To use the library, include ustl.h
and link to -lustl
. Tutorials on using STL are numerous on the web and the information in there mostly applies, except for iostream usage, which is not supported in uSTL for philosophical reasons.
Generated on Mon Jan 17 14:35:02 2005 for uSTL by 1.3.9