TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 229 subscribers
Post #24357 14
PSA: Hidden friends are not reflectable in C++26

Just a curiosity I've come across today, but hidden friends don't seem to be reflectable.

 

Hidden friends are obviously not members of their parent structs, so `meta::members_of` skips them.

Hidden friends also can't be named directly, so `^^hidden_friend` fails with

> error: 'hidden_friend' has not been declared

This seems to match the wording of the standard and isn't just a quirk of the implementation.

 

This also means that /u/hanickadot's [`hana:adl<"hidden_friend">(class_type{})`](https://old.reddit.com/r/cpp/comments/1oaug0f/overload_sets_with_c26s_reflection/) fails to resolve with

> 'res(args...)' would be invalid: type 'hana::overloads<>' does not provide a call operator

In other words, I have good news and bad news.

- Good news: We still can't recreate the core language in the library.
- Bad news: We still can't recreate the core language in the library.

 

EDIT: godbolt links:

- https://godbolt.org/z/jrPdsdYvP - `members_of` demo and "has not been declared" (comment out `getX` implementation to see the output of `members_of`).
- https://compiler-explorer.com/z/eE9GTxzWe - `hana::adl` failing with a hidden friend

https://redd.it/1p7fuu8
@r_cpp
Reddit From the cpp community on Reddit: overload sets with C++26's reflection Explore this post and more from the cpp community
More from @r_cpp
  1. Oct 11, 2026wxWidgets 3.2.12 and 3.3.4 Released https://wxwidgets.org/news/2026/10/wxwidgets-3.2.12-an…
  2. Oct 11, 2026VKRT NES Remaster — an open-source C++20 NES emulator with an observation-driven remasteri…
  3. Oct 11, 2026Right way to test async code https://redd.it/1x2wqgz @r_cpp
  4. Oct 10, 2026Yantra: an LALR(1) parser generator for C++23 Yantra: an LALR(1) parser generator for C++2…
  5. Oct 10, 2026Opting in, and back out again https://dryperspective.github.io/posts/opting-in/ https://re…
  6. Oct 10, 2026I’m Building Bursztyn OS a Polish Operating System From Scratch I’m building Bursztyn OS,…
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 →