Skip to content

ignatz/fab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fab - A Generic C++11 Factory Class

A generic C++11 factory pattern implementation with runtime registration for polymorphic classes. Any function pointer, std::function or non-capturing lambda can be registered for delegated construction.

#include "fab/fab.h"

struct Base { virtual ~Base(){} };
struct A : public Base {};

// ...

Factory<Base> factory;
factory.Register("A", [](int i){ return new A;});

auto ret = factory.Create("A", 42 /* lambda int argument */);
A& a = cast<A>(ret);

// ...

About

A generic C++11 factory class

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published