TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 229 subscribers
Post #24857 16
splice: a C++26 reflection-based hook and signal library

I’ve been experimenting with static reflection in the gcc16 trunk. I’ve built a library that lets you annotate class/struct methods and inject behavior through attributes.

You mark methods as hookable with [[=splice::hook::hookable{}]], then you can inject before/after/return hooks at runtime through a registry. You can cancel calls, override return values, rewrite arguments and control execution order by changing the priority of your hooks, all without touching the original class.

It also has a wire system for signal/slot connections. Slots declare which signal they handle via reflection attributes, and you can connect specific, or all signals on a listener. Listeners can also be paused, resumed, and they automatically disconnect when destroyed via RAII. If you want to wire a listener to for example, an on_click method on a class, you just add an attribute: [[SPLICE_WIRE_SLOT(.signal = ^^MyClass::on_click)]]

This currently requires GCC 16 (built from a snapshot) and the -freflection compiler flag. Still early, but all the tests pass and the API feels simple to use. Eventually, I want to use the same reflection machinery to generate FFI bindings for Lua, and maybe other scripting languages too.

GitHub: https://github.com/FloofyPlasma/splice

Curious if anyone else is experimenting with the reflection coming in C++ 26.

https://redd.it/1rxj838
@r_cpp
GitHub GitHub - FloofyPlasma/splice: A header-only C++26 reflection-based hook and mixin library A header-only C++26 reflection-based hook and mixin library - FloofyPlasma/splice
More from @r_cpp
  1. Oct 7, 2026Full Meeting C++ 2026 program released https://meetingcpp.com/mcpp/schedule/#2026 https://…
  2. Oct 7, 2026Qt moc now can handle basic C++ modules (Qt 6.12) https://codereview.qt-project.org/c/qt/q…
  3. Oct 7, 2026New to c++ Hello everybody,im new to cpp,and want to learn it,i have some knowledge with C…
  4. Oct 7, 2026Optimizing the Compressed Log Pipeline: https://github.com/Tencent/BqLog/blob/main/docs/Ar…
  5. Oct 7, 2026BqLog 2.6.0: a C++ logging library running on 30M+ devices daily, benchmarked against quil…
  6. Oct 7, 2026BqLog 2.6.0: a C++ logging library running on 30M+ devices daily, benchmarked against quil…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →