Fit is a header-only C++11/C++14 library that provides utilities for functions and function objects, which can solve many problems with much simpler constructs than whats traditionally been done with metaprogramming.

Fit is:

  • Modern: Fit takes advantages of modern C++11/C++14 features. It support both constexpr initialization and constexpr evaluation of functions. It takes advantage of type deduction, varidiac templates, and perfect forwarding to provide a simple and modern interface.
  • Relevant: Fit provides utilities for functions and does not try to implement a functional language in C++. As such, Fit solves many problems relevant to C++ programmers, including initialization of function objects and lambdas, overloading with ordering, improved return type deduction, and much more.
  • Lightweight: Fit builds simple lightweight abstraction on top of function objects. It does not require subscribing to an entire framework. Just use the parts you need.

Fit is divided into three components:

  • Function Adaptors and Decorators: These enhance functions with additional capability.
  • Functions: These return functions that achieve a specific purpose.
  • Utilities: These are general utilities that are useful when defining or using functions




  • Improve the expressiveness and capabilities of functions, including first-class citzens for function overload set, extension methods, infix operators and much more.
  • Simplify constructs in C++ that have generally required metaprogramming
  • Enable point-free style programming
  • Workaround the limitations of lambdas in C++14


This requires a C++11 compiler. There are no third-party dependencies. This has been tested on clang 3.4-3.7, gcc 4.6-4.9, and Visual Studio 2015. Gcc 5.1 is not supported at all.

Contexpr support

Both MSVC and gcc 4.6 have limited constexpr support due to many bugs in the implementation of constexpr. However, constexpr initialization of functions is supported when using the FIT_STATIC_FUNCTION and FIT_STATIC_LAMBDA_FUNCTION constructs.


The Fit library uses cmake to build. To configure with cmake create a build directory, and run cmake:

mkdir build
cd build
cmake ..


To install the library just run the install target:

cmake --build . --target install


The tests can be built and run by using the check target:

cmake --build . --target check


The documentation is built using Sphinx. First, install the requirements needed for the documentation using pip:

pip install -r doc/requirements.txt

Then html documentation can be generated using sphinx-build:

sphinx-build -b html doc/ doc/html/

The final docs will be in the doc/html folder.

Related Repositories



Fit things into other things ...



Polyfill (mostly IE) for CSS object-fit property to fill-in/fit-in images into containers. ...



Fit Chart is an Android view similar to Google Fit wheel chart. ...



Responsive image component to fit perfectly itself. ...



A PHP class for analysing FIT files created by Garmin GPS devices ...

Top Contributors

pfultz2 ldionne tzlaine bcachet drodri


-   v0.4 zip tar
-   v0.3 zip tar
-   v0.2 zip tar
-   v0.1 zip tar