$ show google/fruit
Fruit is a C++ dependency injection framework that enforces binding correctness at compile time through heavy template metaprogramming, loosely inspired by Google Guice for Java. The core architecture consists of a public fluent API (Component, Injector, Provider, NormalizedComponent) backed by an internal metaprogramming library for compile-time validation and runtime graph traversal using custom high-performance data structures (SemistaticGraph, SemistaticMap, FixedSizeAllocator). Users declare components via createComponent() chaining, which produces type-safe binding graphs; the framework then generates efficient object construction code with lazy/eager injection, multibindings, and component replacement for testing. The repository also includes a comprehensive benchmark suite that compares Fruit against Boost.DI and hand-written injection, along with parallel build system support (CMake, Bazel, Conan) and cross-platform CI covering GCC, Clang, MSVC across Linux, macOS, and Windows.
The LLM identified 3 files worth highlighting for reuse:
Implements a compile-time vector (type-level list) with operations such as push, pop, concatenate, transform, and fold. This is a standalone metaprogramming utility that could be extracted as a header-only library for type-list manipulations in any C++11+ project, demonstrating sophisticated variadic template and partial specialization techniques.
A graph data structure that supports both static (pre-built) edges and dynamic post-construction additions, optimized for fast traversal and low memory overhead. Uses pointer packing and uintptr_t tricks for efficient edge representation. The design patterns (separating static and dynamic nodes, lazy terminal conversion) are transferable to any application needing a performant, memory-efficient graph with a mostly fixed topology.
A Python script that generates synthetic C++ benchmark codebases for comparing DI frameworks. It creates directed injection graphs (via networkx) and produces compilable sources for Fruit, Boost.DI, and a no-DI baseline, including user-specified binding patterns, multibindings, and interfaces. This pattern of automated source generation for comparative performance experiments is reusable for any library evaluation.