232 5. Engine Support Systems
bug, it will ultimately be your team’s responsibility to work around it
or fi x it.
- Backward compatibility may not be supported.
- The Boost libraries are distributed under the Boost Soft ware License.
Read the license information (htt p://www.boost.org/more/license_info.
html) carefully to be sure it is right for your engine.
Loki
There is a rather esoteric branch of C++ programming known as template meta-
programming. The core idea is to use the compiler to do a lot of the work that
would otherwise have to be done at runtime by exploiting the template fea-
ture of C++ and in eff ect “tricking” the compiler into doing things it wasn’t
originally designed to do. This can lead to some startlingly powerful and use-
ful programming tools.
By far the most well-known and probably most powerful template meta-
programming library for C++ is Loki, a library designed and writt en by Andrei
Alexandrescu (whose home page is at htt p://www.erdani.org). The library can
be obtained from SourceForge at htt p://loki-lib.sourceforge.net.
Loki is extremely powerful; it is a fascinating body of code to study and
learn from. However, its two big weaknesses are of a practical nature: (a) its
code can be daunting to read and use, much less truly understand, and (b)
some of its components are dependent upon exploiting “side-eff ect” behav-
iors of the compiler that require careful customization in order to be made
to work on new compilers. So Loki can be somewhat tough to use, and it
is not as portable as some of its “less-extreme” counterparts. Loki is not for
the faint of heart. That said, some of Loki’s concepts such as policy-based pro-
gramming can be applied to any C++ project, even if you don’t use the Loki
library per se. I highly recommend that all soft ware engineers read Andrei’s
ground-breaking book, Modern C++ Design [2], from which the Loki library
was born.
5.3.4.2. Dynamic Arrays and Chunky Allocation
Fixed-size C-style arrays are used quite a lot in game programming, because
they require no memory allocation, are contiguous and hence cache-friendly,
and support many common operations such as appending data and searching
very effi ciently.
When the size of an array cannot be determined a priori, programmers
tend to turn either to linked lists or dynamic arrays. If we wish to maintain the
performance and memory characteristics of fi xed-length arrays, then the dy-
namic array is oft en the data structure of choice.