---
title: "C++ Reflection: a Universal Printer"
url: https://daily.dev/posts/c-reflection-a-universal-printer-pmscycfou
source_url: https://accu.org/journals/overload/34/193/decock
type: article
source: "C++"
published: 2026-08-05T21:43:52.243Z
updated: 2026-08-05T23:00:22.174Z
tags: ["c++"]
reading_time: 14
upvotes: 1
comments: 0
language: 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.

# C++ Reflection: a Universal Printer

**[C\+\+](https://daily.dev/sources/isocpp)** · 14 min read · 1 upvotes · 0 comments

## Summary

C++26 introduces static reflection, and this tutorial demonstrates how to build a universal printer/formatter using it. Starting with the lift operator (^^) to enter the reflection domain and the splice operator ([: :]) to return to the code domain, the guide walks through querying struct members via nonstatic_data_members_of(), handling access contexts (public vs private), and implementing a custom std::formatter. The tutorial progressively covers inheritance (bases_of()), unnamed types (has_identifier()), and enum formatting (enumerators_of()), culminating in a complete UniversalFormatter that can print any struct's members — including private ones and base class fields — by name and value.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://accu.org/journals/overload/34/193/decock>

## Similar posts on daily.dev

- [Flavours of Reflection — Semantics](https://daily.dev/posts/flavours-of-reflection-semantics-b70oldr8z) · C\+\+ · 1 upvotes · 0 comments

---

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

[View this post on daily.dev](https://daily.dev/posts/c-reflection-a-universal-printer-pmscycfou)
