<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/lightning-talk-emulators-all-the-way-down---koen-samyn-zc34dsy68" -->

---
title: Lightning Talk: Emulators All the Way Down - Koen Samyn
description: A lightning talk demonstrates using C++26's reflection features (std::meta, substitute, splice) to build a tiny stack-based virtual machine. The speaker walks...
canonical: https://daily.dev/posts/lightning-talk-emulators-all-the-way-down---koen-samyn-zc34dsy68
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Lightning Talk: Emulators All the Way Down - Koen Samyn | daily.dev
og:description: A lightning talk demonstrates using C++26's reflection features (std::meta, substitute, splice) to build a tiny stack-based virtual machine. The speaker walks...
og:url: https://daily.dev/posts/lightning-talk-emulators-all-the-way-down---koen-samyn-zc34dsy68
og:image: https://api.daily.dev/og/posts/zc34dSY68.png
og:image:alt: Lightning Talk: Emulators All the Way Down - Koen Samyn
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Lightning Talk: Emulators All the Way Down - Koen Samyn

**[C\+\+Online](https://daily.dev/sources/cpponline)** · 6 min read · 0 upvotes · 0 comments

## Summary

A lightning talk demonstrates using C++26's reflection features (std::meta, substitute, splice) to build a tiny stack-based virtual machine. The speaker walks through encoding op codes as bytes, using a templated execute function, and leveraging reflection to instantiate specific template versions at compile time, then splicing them into function pointers. The result compiles op codes into inlinable functions, effectively 'compiling' the program at build time and removing runtime dispatch overhead typical of emulator switch-statements. The talk closes noting broader applications for data-oriented programming, such as embedding game ROMs or compiling stored functionality into optimized code.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=7DFSCTNBecc>

## Questions this post answers

### How can I use C++26 reflection to build an emulator without a giant switch statement?

C++26 reflection lets you reflect an execute function template, then use substitute to generate a specific instantiation for each op code, and splice to convert that instantiation into a function pointer stored in an array. This effectively compiles the program's instructions into directly callable, inlinable functions instead of relying on runtime dispatch through a switch statement.

_Developers exploring cutting-edge C++26 reflection features can track real-world examples like this on daily.dev._

### What does the substitute function do in C++26 reflection?

Substitute creates a specific instantiation of a template using reflection metadata, effectively compiling a generic templated function into a concrete version for particular arguments, such as a specific op code and operand. This instantiation can then be spliced back into code, decaying into a function pointer that can be stored and called directly.

_Anyone experimenting with C++26 metaprogramming can follow practical walkthroughs like this via daily.dev._

## Similar posts on daily.dev

- [Pushing the limits of RISC-V emulation](https://daily.dev/posts/pushing-the-limits-of-risc-v-emulation-dxh7xvq1d) · Hacker News · 0 upvotes · 0 comments
- [Making a game on a custom bytecode VM in 7 days and 3kB](https://daily.dev/posts/making-a-game-on-a-custom-bytecode-vm-in-7-days-and-3kb-5cqpsofln) · Lobsters · 0 upvotes · 0 comments

---

Tags: [#c++](https://daily.dev/tags/c++)

[View this post on daily.dev](https://daily.dev/posts/lightning-talk-emulators-all-the-way-down---koen-samyn-zc34dsy68)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Lightning Talk: Emulators All the Way Down - Koen Samyn","url":"https://daily.dev/posts/lightning-talk-emulators-all-the-way-down---koen-samyn-zc34dsy68","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/lightning-talk-emulators-all-the-way-down---koen-samyn-zc34dsy68"},"datePublished":"2026-08-24T16:08:12.158Z","dateModified":"2026-08-24T16:08:30.513Z","description":"A lightning talk demonstrates using C++26's reflection features (std::meta, substitute, splice) to build a tiny stack-based virtual machine. The speaker walks...","image":"https://i.ytimg.com/vi/7DFSCTNBecc/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/7DFSCTNBecc/sddefault.jpg","isAccessibleForFree":true,"articleSection":"C++Online","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"C++Online","logo":"https://media.daily.dev/image/upload/s--8WzMvjLJ--/f_auto,q_auto/v1783236334/logos/cpponline","url":"https://daily.dev/sources/cpponline"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/lightning-talk-emulators-all-the-way-down---koen-samyn-zc34dsy68","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"c++","timeRequired":"PT6M","video":{"@type":"VideoObject","name":"Lightning Talk: Emulators All the Way Down - Koen Samyn","description":"A lightning talk demonstrates using C++26's reflection features (std::meta, substitute, splice) to build a tiny stack-based virtual machine. The speaker walks...","thumbnailUrl":"https://i.ytimg.com/vi/7DFSCTNBecc/sddefault.jpg","uploadDate":"2026-08-24T16:08:12.158Z","duration":"PT6M","url":"https://api.daily.dev/r/zc34dSY68","embedUrl":"https://www.youtube.com/embed/7DFSCTNBecc"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"C++Online","item":"https://daily.dev/sources/cpponline"},{"@type":"ListItem","position":3,"name":"Lightning Talk: Emulators All the Way Down - Koen Samyn"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/lightning-talk-emulators-all-the-way-down---koen-samyn-zc34dsy68#faq","mainEntity":[{"@type":"Question","name":"How can I use C++26 reflection to build an emulator without a giant switch statement?","acceptedAnswer":{"@type":"Answer","text":"C++26 reflection lets you reflect an execute function template, then use substitute to generate a specific instantiation for each op code, and splice to convert that instantiation into a function pointer stored in an array. This effectively compiles the program's instructions into directly callable, inlinable functions instead of relying on runtime dispatch through a switch statement. Developers exploring cutting-edge C++26 reflection features can track real-world examples like this on daily.dev."}},{"@type":"Question","name":"What does the substitute function do in C++26 reflection?","acceptedAnswer":{"@type":"Answer","text":"Substitute creates a specific instantiation of a template using reflection metadata, effectively compiling a generic templated function into a concrete version for particular arguments, such as a specific op code and operand. This instantiation can then be spliced back into code, decaying into a function pointer that can be stored and called directly. Anyone experimenting with C++26 metaprogramming can follow practical walkthroughs like this via daily.dev."}}]}
```

