Loki is a C++ library of designs, containing flexible implementations of common design patterns and idioms. It was originally authored by Andrei Alexandrescu, to accompany his now well-known book "Modern C++ Design" (ISBN: 978-0-201-70431-0). It is distributed under the MIT license.
Latest "release" version: 0.1.7 (January 2009)
-
Official upstream: http://loki-lib.sourceforge.net/
-
Friendly fork based on a mirror to Git, with fixes for modern compilers and other small updates: https://github.com/rpavlik/loki-lib
-
Maintained by Ryan Pavlik, http://academic.cleardefinition.com
-
Works great as a Git submodule.
-
Pull requests happily accepted!
-
To use Loki, simply extract the files from the archive, give your compiler access to their include path:
-
if you have a standard conforming compiler use
loki/includefor#include <loki/HeaderFile.h>usage -
if you have a non-conforming compiler (really, really old) use
loki/include/nonccfor#include <loki/HeaderFile.h>usage. Thenonccfiles are declared as 'deprecated' and will be removed in future. They are also not updated with the new features of Loki and bugfixes (unless you do it and submit a pull request).
Much of Loki only needs header files. However, a few features require
implementations found in .cpp source files, rather than inline in
headers.
Add these source files to your project/makefile if your usage meets the corresponding description.
Note: Items marked with (?) might be too broad - that is, some uses in the description don't actually require the source file. If you can clarify any of these, please fork and pull request.
-
src/LevelMutex.cpp: if you use the<loki/LevelMutex.h>header. -
src/OrderedStatic.cpp: if you use the<loki/OrderedStatic.h>header. -
src/SafeFormat.cpp: if you use the<loki/SafeFormat.h>header. (?) -
src/Singleton.cpp: if you use "Singletons with longevity" -
src/SmallObj.cpp: If you use the small object allocator directly or indirectly. Indirect uses include:-
The
Functorclass -
The
<loki/Allocator.h>header (?) -
The
<loki/SmartPtr.h>header (?) -
Any
Factory-related functionality (?)
-
-
src/SmartPtr.cpp: if you use the<loki/SmartPtr.h>header. -
src/StrongPtr.cpp: if you use the<loki/StrongPtr.h>header.
Of course, you could also use the library generated by make.msvc.bat,
make.mingw.bat, or make instead of adding those sources to your project.
Please do add to this list!
(Git commit ID tested follows in parentheses.)
- gcc version 4.4.3 on x86_64-linux-gnu (commit f1fb80a7d)
- clang version 3.2 (trunk 164641) on x86_64-linux-gnu (commit f1fb80a7d)
- Microsoft Visual C++ 2008 SP1 (commit b50a1c3bc)
- Microsoft Visual C++ 2010 (commit b50a1c3bc)
This was the previous compatibility list found in the README.
- Gcc v3.4
- Gcc v4.0
- Gcc v4.1
- Microsoft Visual C++ v7.1
- Microsoft Visual C++ v8.0
by special noncc files:
- Borland C++ Builder v6.0
- Microsoft Visual C++ v6.0
- Microsoft Visual C++ v7.0
see also readme.txt files
Mostly Supported:
- CodeWarrior 6.0
CodeWarrior has a problem with the Conversion template (see
TypeManip.h) and, though it compiles it, it doesn't provide correct results. Consequently, theDerivedToFrontalgorithm inTypelist.hdoes not function. This affects the static dispatcher inMultimethods.h. As a fix, you must order the types (putting the most derived ones in the front) when providing the typelist argument toStaticDispatcher.
- Andrei's page: http://erdani.org
- Sourceforge project page: http://sourceforge.net/projects/loki-lib/
- Automated Git mirror of upstream Sourceforge SVN: https://github.com/vancegroup-mirrors/loki-lib