r/cpp • • Sep 22 '26

Stateful compile-time functions

In section 9.1.2 of this book[1] it mentions that C++23 allows for stateful constexpr functions, and even shows an example. I can't seem to get it to compile on godbolt. Is the book completely wrong about something so fundamental, or am I doing something wrong?

[1] https://simplifycpp.org/books/cpp/Mastering_Modern_C++23_A_Complete_Guide_to_the_Latest_Standard.pdf

Edit: Godbolt link with code from that section -> https://godbolt.org/z/94j9EK87b

0 Upvotes

10 comments sorted by

View all comments

Show parent comment

12

u/PowerShartOffice Sep 22 '26

The author has a post on LinkedIn titled "How I Authored Over 200 Specialized Technical Books with the Help of Al (And Why I Decided to Publish Them for Free)"