You are here: Start » Introduction » Fab Template Library

Fab Template Library

FabImage Library is based on the Fab Template Library – a simplified counterpart of the C++ Standard Template Library, which avoids advanced templating techniques mainly by using raw pointers instead of abstract iterators. This makes FabImage Library portable to embedded platforms, including the ones that do not support C++ templates fully.

Please note, that the following types should only be parametrized with fundamental types (int, float, etc.) or types from fil or ftl namespace. Const and/or reference types are also allowed, as long as template type accepts such type (e.g. Array<T> cannot be parametrized with reference type).


The Array<T> type strictly corresponds to std::vector<T>. It is a random-access, sequential container with automatic memory reallocation when growing.

Here is a simplified version of the public interface is depicted: Array.h


The Optional<T> type provides a consistent way of representing an optional value, something for which NULL pointers or special values (such as -1) are often used. Many APIs provide optional values using default values of parameters. This type is inspired by boost::optional<T> class from the Boost Library, but is designed mostly for input parameters, not only for function results.

In FabImage Library it is used to represent optional regions of interest in image processing operations and many other input parameters that can be determined automatically when not provided by an user.

Documentation for this type is presented in Optional.h.

Sample use:

ftl::Optional<fil::Point2D> p;
p = fil::Point2D(10, 25);        // normal value
p = ftl::NIL;               // NIL value
if (p != ftl::NIL)
	fil::Point2D q = p.Get();    // access to a non-nil value
	p.Get().x = 15;         // direct access to a field


This type of data is especially used to determine invalid results. Many functions in C return special value as -1 or NULL when their result is invalid. Type Conditional<T> is very similar to Optional<T>, but it is mostly used in outputs.

Documentation for this type is presented in Conditional.h.

Sample use:

ftl::Conditional<int> result;
fil::ParseInteger("Test1", fil::NumberSystemBase::Base_10, result);	// Parsing textual data

if (result != ftl::NIL)			// If textual data is not valid integer result has value ftl::NIL
	printf("Valid integer.");
	printf("Invalid integer. Value: %d", result.Get());


Dummy<T> class is used to create a temporary object that will be released after its use. It is mostly used to create a temporary object to pass its reference to a function. Such temporary objects are helpful when not all values returned by a function are important and we don't plan to use them.

Sample use:

fil::Region region;
fil::Circle2D circle = fil::Circle2D(50.0f, 50.0f, 50.0f);

fil::CreateCircleRegion(circle, ftl::NIL, 100, 100, region);

// Second parameter is not used.
fil::Segment2D minorAxis;
fil::RegionEllipticAxes(region, ftl::Dummy<fil::Segment2D>(), minorAxis);

std::cout << "Minor axis length: " << minorAxis.Length();
Previous: Programming Conventions Next: Getting Started