Skip to content

Add tutorials for type-erasure, reflection and vanishing-this - #96

Open
jbcoe wants to merge 27 commits into
mainfrom
tutorials
Open

Add tutorials for type-erasure, reflection and vanishing-this#96
jbcoe wants to merge 27 commits into
mainfrom
tutorials

Conversation

@jbcoe

@jbcoe jbcoe commented Jul 22, 2026

Copy link
Copy Markdown
Owner

I'm not entirely sure that these tutorials are necessary.

The act of writing them was useful and perhaps they will be useful to readers of the (increasingly novel and technical) code in #95.

@jbcoe
jbcoe force-pushed the tutorials branch 2 times, most recently from 4d2bd17 to 321b94c Compare July 22, 2026 19:53
@jbcoe
jbcoe requested a review from Twon July 22, 2026 22:18
@jbcoe
jbcoe marked this pull request as ready for review July 22, 2026 22:18
@Twon

Twon commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

I think these are great, first 2 down and working through the 3rd now, but these are definitely useful (I'm learning reflection from the 3rd).

Perhaps the files could be renamed with a number indicating the order of the tutorials?

  1. 1_type_erasure.cc
  2. 2_vanishing_this_pointer
  3. 3_reflection.cc

The pedant in me finds it odd to start in the middle, go down and then go up in the file view in VSCode.

Comment thread tutorials/3_reflection.cc
Comment thread tutorials/3_reflection.cc
@jbcoe
jbcoe requested review from RyanJK5 and Twon July 23, 2026 09:54
Comment thread tutorials/2_vanishing_this_pointer.cc
Comment thread tutorials/3_reflection.cc
@jbcoe
jbcoe requested a review from RyanJK5 July 24, 2026 18:30

@RyanJK5 RyanJK5 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just gave the tutorials an in-depth look, and I think they are very good! All of the information is accurate. I left some comments, mostly regarding additional pieces of the reflection tutorial worth acknowledging. Thanks for putting these together!

Comment thread tutorials/2_vanishing_this_pointer.cc
Comment thread tutorials/2_vanishing_this_pointer.cc
Comment thread tutorials/2_vanishing_this_pointer.cc Outdated
Comment thread tutorials/2_vanishing_this_pointer.cc Outdated
Comment thread tutorials/3_reflection.cc
Comment thread tutorials/3_reflection.cc Outdated
Comment thread tutorials/3_reflection.cc
Comment thread tutorials/3_reflection.cc
Comment thread tutorials/3_reflection.cc Outdated
Comment thread tutorials/3_reflection.cc
@jbcoe

jbcoe commented Jul 25, 2026

Copy link
Copy Markdown
Owner Author

@RyanJK5 thanks for the detailed review comments. This is exactly what’s needed for foundational material. Thanks for taking the time.

@jbcoe
jbcoe requested a review from RyanJK5 July 26, 2026 16:52

@RyanJK5 RyanJK5 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me now, thanks for making those changes!

Comment thread tutorials/3_reflection.cc Outdated
@jbcoe
jbcoe requested a review from Twon July 28, 2026 20:23
Comment thread tutorials/3_reflection.cc
}

TEST(ReflectionHelpers, ClassifiesConstCorrectly) {
constexpr auto read_candidates =

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personal I'd perfer concept constrained auto here because being unfamilar with this function, and with no explanation of its use, I had to go to C++ ref and read the documentation to be confident I know what was happening. I think the hint is a range is enough knowledge to skip this step

Suggested change
constexpr auto read_candidates =
constexpr std::ranges::range auto read_candidates =

Comment thread tutorials/3_reflection.cc
TEST(ReflectionHelpers, ClassifiesConstCorrectly) {
constexpr auto read_candidates =
std::define_static_array(members_named(^^Widget, "read"));
constexpr auto write_candidates =

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again concept-constrained auto

Suggested change
constexpr auto write_candidates =
constexpr std::ranges::range auto write_candidates =

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants