C++ Metaprogramming Primivites and Pattern implementations.
This library is kept deliberately small, with no external dependencies.
for.hprovides compile-time for loops
comparison.hprovides compile-time comparators
noncopyable.hprovides a non-copyable base class
mandatory.hprovides code for enforcing checking of return types
byteorder.hprovides compiler-/platform-independent versions of ntoh/hton for integer types (including 64 bits)
pointers.hprovides policies for shallow-copying/deep-copying pointer members.
typelist.hprovides constructs for constructing and manipulating lists of types.
typelistis a list of types with no value to itself.
inheritancelistinherits from all types and therefore does not work with POD types.
compositionlistcomposes all types and therefore does work with POD types.
condition.htypes for compile-time composition of condition chains with conditions being either stateless or stateful.
math.hfor some simple compile-time mathematics, such as keeping a ratio of two numbers and converting into another ratio, etc.
nullptrsupport in compilers that don't know it yet.
singleton.hfor a simple singleton implementation.
restrictions.hfor types that allow only certain ranges of values to be assigned to them; you can use them in a function prototype to enforce a contract, for example.
Some of these bits of code started out as mental exercises, so there's no guarantee for usefulness implied in providing them. See COPYING for details.
- OS X
- Arm (hardfloat)
- MIPS (big endian)
- Visual Studio
There are external dependencies, but only for testing:
Similarly, external dependencies for building on CI are:
Follow the instructions to add the Ubuntu PPA to your system. Then run (as root):
apt-get install libmeta-dev
This will install the (empty) binary package file as well as the development headers.
After installing the requirements, run:
$ cmake .
This will configure the build system. Usually, you can just run the following commands to get going:
$ make testsuite && ./testsuite
CMake already defines the
Debug build types. In addition to
these, meta offers a
Coverage build type which is largely indentical to
Debug, but with GCC offers code coverage generation.
To specify a build type, use e.g.
$ cmake . -DCMAKE_BUILD_TYPE=Coverage
For compiling code coverage information, just run the
$ make coverage
This library is mostly written with
C++11 features in mind, but some of it's
code can also compile in
C++98. A few headers can be compiled in either mode.
meta into building only
c++98 compatible tests, invoke
$ cmake -DMETA_USE_CXX11=OFF .
Similarly, if you're including meta headers into your
C++98 project, make
sure to set the same define - either before the include statement, or on the
The build.sh script uses
to create a suitable build environment on CI, possibly on emulated hardware.
$ ./build.sh x86_64 $ ./build.sh mips