The FreeBASIC Standard C++ Library Port (fbstd)

A crossplatform implementation of the C++ Standard Library written in FreeBASIC

News ] [ Overview ] [ Download ] [ Documentation ] [ Links ]


Friday, May 4th, 2007
    stylin -
Website launched. Enjoy :)
    stylin - Initial beta (0.03b) released. Get it here.

[ back to top ]


The FreeBASIC Standard C++ Library Port, or fbstd, is a cross-platform FreeBASIC implementation (is that redundant ?) of the generic containers, iterators, algorithms and streams of the C++ Standard Library, released under the GPL. It aims to be fast and user-friendly, while providing a similar level of extensibility you get from C++.

fbstd provides 4 main areas of abstraction: containers, iterators, algorithms and streams.

Containers are objects which hold a number of elements of a certain type, and provide guarantees as to how those elements are inserted, removed and accessed. fbstd.List, counterpart to C++'s std::list, stores elements in a doubly-linked list, so that insertion and removal of elements happens in constant time, while traversal is linear. fbstd.Vector, counterpart to C++'s std::vector, stores elements in an array-like structure, so elements can be randomly accessed (in constant time), but insertion and removal are not in constant time.

Iterators are objects which act like pointers with respect to a certain container, and are used to traverse - or, iterate through - a container's set of elements. Since different containers may - and do - store elements differently from one another, there exists different ways to traverse them. So every container provides its own iterator type, suitable for iterating through its elements.

Algorithms are procedures that work with iterators to provide some kind of function on a range of elements. For example, fbstd.Reverse, counterpart to C++'s std::reverse, is a procedure that takes two iterators denoting a range, and reverses the elements in that range. Since algorithms only work with iterators, it allows them to be used with a range of elements of any container which provides its own iterator type.

Streams abstract the input or output to or from some place, such as a disk file, a buffer or some other place. Streams [optionally] handle the bufferring of that i/o and [optionally] its formatting.!!writeme!!

fbstd is based primarily off of GCC's implementation, The GNU Standard C++ Library v3. The algorithms, in particular, are basically straight ports from C++ to FreeBASIC code. With all ports of code between fundamentally different languages, nearly all of the design is there, however its application varies - sometimes quite wildly. For lack of templates, for example, certain types have been created to act as 'base classes' for others. fbstd.Iterator, for instance, is a generic iterator type which encapsulates the behavior of a particular concrete iterator. All of the container's iterators can be cast to this type, and it is this type that all of the algorithms accept as parameters. Not to mention that FreeBASIC - like fbstd - is a work in progress, so certain design issues are centered around issues in FreeBASIC. Various bugs, for example, force a design change to workaround.

But, aside from some small and large implementation differences, the concepts are still there: containers, iterators, algorithms and streams. Because these concepts remain - and because FreeBASIC is more and more starting to support many of the constructs present in C++ - code designed to use this library isn't much different than its would-be C++ counterpart. (although, I don't see FreeBASIC supporting templates any time soon..)

[ back to top ]


The source code and binary builds for fbstd can be downloaded here: The latest source code can also be viewed on-line here:

For Windows users, a pre-built static library is provided. Linux and DOS users can easily build a static library from the source; look in ./README for instructions. (installation instructions will be printed here eventually).

Currently only a static library can be built using the build system (with or without debugging information). Support for shared libraries is in planning.

[ back to top ]


While no documentation exists at this time - sorry ! - the package does include some example code that should explain at least the basic usage of the library.

I'd recommend browsing through some C++ tutorial/reference sites, such as, to get an overall picture of what this library is all about. Obviously, lacking inheritance and templates of any kind, much of the usage - especially in construction of the various objects - is going to differ remarkably. Again, the example code provided should be enough information to begin using the library.

[ back to top ]


fbstd project page []
FreeBASIC official site []
FreeBASIC official forums []
FreeBASIC Manual []

[ back to top ]

All web content Copyright(c) 2007 Laanan Fisher