🍥 A new take on polymorphism in C++
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
build Removed unused precompiled_header.cmake Feb 12, 2018
compiler/perf Building compilation time benchmark with msvc Jul 7, 2018
doc Moved logos to lowercas directory. Added license info Aug 18, 2018
example Experimenting with programatically defining mixins Jul 29, 2018
gen Replaced caller template instantiation with no-capture lambdas Aug 19, 2018
include Update comment for the new behavior of message functions Aug 19, 2018
perf Latest picobench Feb 12, 2018
src Function which allows the user to garbage collects unused object type… Jul 7, 2018
.travis.yml Reintroduces mixin names by typeid. Fixes #23 Jun 30, 2018
CMakeLists.txt Disabled build of most targets if we're not the cmake source dir Aug 30, 2018
LICENSE Updated copyright year Jan 1, 2018
appveyor.yml Temporarily disabled AppVeyor cache Mar 18, 2018



Language Standard License Gitter

Travis CI AppVeyor

Meeting CPP Badge

DynaMix (Dynamic Mixins) is a new take on polymorphism. It lets the user compose and modify polymorphic objects at run time in C++.

The library is a means to create a project's architecture rather than achieve its purpose. It focuses on maximal performance and minimal memory overhead.

DynaMix is great for the software architecture of systems with very complex objects including, but not limited to:

  • Games (especially role-playing ones or strategies)
  • CAD systems
  • Enterprise systems
  • UI libraries

The library uses the type dynamix::object as a placeholder, whose instances can be extended with existing classes (mixins), thus providing a particular instance with the functionality of all those types. Accessing the newly formed type's interface is made through messages – stand-alone functions generated by the library, which can be thought of as methods.

Here is a small example of what your code may look like if you use the library:

    // assuming my_objects.get_ally(0); is a way to get an ally to the
    // main character in a game
    dynamix::object& obj = my_objects.get_ally(0);

    // now let's make the object think some positive thoughts about the
    // main character

    think(obj); // C++ doesn't allow us to have obj.think().
                // DynaMix's messages are standalone functions

    // composition

    // object can now respond to fly()

    fly(obj); // ...instead of obj.fly()

    // mutation

    think(obj); // the same object now thinks negative thoughts about the main
                // character, since it's no longer an ally, but an enemy

Here are some of the key features of the library:

  • Compose objects from mixins at run time
  • Physically separate interface and implementation
  • Fast polymorphic calls – comparable to std::function
  • No external dependencies other than the standard library
  • Non-intrusive – mixins don't need to have a common parent or any special code inside
  • Mutate "live" objects by changing their composition at run time
  • Have multicast messages, which are handled by many mixins within an object
  • Possibility to have custom allocators to finely tune the memory and aim for cache-locality for critical parts of the code
  • Ability to have dynamic libraries that can enrich or modify objects, without modifying, or even rebuilding, the executable.
  • Thread safe message calls – as thread safe as the underlying methods.

You can also check out the talk about DynaMix from C++ Russia 2018 or the article about it in ACCU's Overload Journal from April, 2018.

C++ Russia video on YouTube

Created with DynaMix

The following projects are known to use DynaMix as a key piece of their software architecture:

There are two more known mobile games in development which use it. They will be added to this list upon release.


The full documentation is available at the GitHub page of the library


Several small fully working annotated tutorial programs are provided with the library:

  • Basic – a program which illustrates the basic usage of DynaMix. It's a tutorial on creating mixins and messages, and creating and modifying (or mutating) objects.
  • Messages – a tutorial which takes a deeper look at creating and calling the various types of messages.
    • Message bids – a tutorial which takes a deeper look at calling and overriding messages.
  • Mutation – a tutorial about the various ways by which objects can be created and mutated.
    • Mutation rules – a deeper look at the library's capabilities for automatic object mutation.
  • Combinators – a tutorial about handling the return type of multicast messages.
  • Allocators – a tutorial about using the library's mixin allocators.
  • Serialization – a tutorial which looks at the possibilities available for serializing objects.


There is an accompanying CMakeLists.txt file in the repo. Use CMake to generate project or make files for your desired platform and compiler.


Contributions in the form of issues and pull requests are welcome.


This software is distributed under the MIT Software License.

See accompanying file LICENSE or copy here.

Copyright © 2013-2018 Borislav Stanimirov, Zahary Karadjov


The DynaMix logo is licensed under a Creative Commons Attribution 4.0 International License. Copyright © 2018 area55git

License: CC BY 4.0.


DynaMix was initially developed as Boost.Mixin but is now a separate library, that doesn't depend on the Boost libraries Collection.

DynaMix, unlike Boost.Mixin, has no C++98 support. It's C++11 only.

DynaMix is distributed under the MIT license, whereas Boost.Mixin is distributed under the Boost Software License.