r/cpp • u/VinnieFalco wg21.org | corosio.org • 2d ago
CppCon CppCon 2026 Keynote: C++: Profiles for Simplicity and Guarantees -- Bjarne Stroustrup
https://isocpp.org/blog/2026/09/cppcon-2026-keynote-cpp-profiles-for-simplicity-and-guarantees-bjarne-strou5
u/_space_ghost_ 1d ago
I think this talk will answer some of the questions found in the original OP link:
https://cppcon2026.sched.com/event/2RT6a/c++-core-guidelines-enforcement-in-practice
(edit, rephrasing)
27
u/VinnieFalco wg21.org | corosio.org 2d ago
I'm looking forward to this. I will be at CppCon if anyone wants to meet up and talk shop! if you are attending, check out the C++ Alliance pavilion where we will be revealing the Boost Collectable Card Game! Visit https://ccg.boost.org/
7
u/rayaxiom 2d ago
There's an official card game from boost?! Wow. I see I can play against the compiler, is online pvp available? Make it available on steam!
5
25
u/PossibilityUsual6262 2d ago
Honestly, i don't have anything from Bjarne in recent memory which wasn't delusional marketing nonsense of no value, lets see if this is not like others.
9
u/Orlha 2d ago
observer_ptr counter-paper was alright
2
u/donaljones 2d ago
A bit off-topic, but what might it be useful for?
8
u/AnyPhotograph7804 2d ago
It was intended to replace T*. Because if you see a naked pointer, you cannot see, whether it owns a ressource or not by looking at the type itself. You have to read the sourcecode to understand what is going on. By looking at experimantal::observer_ptr you would see, that this pointer is a non-owning pointer.
0
u/scrumplesplunge 1d ago
I feel like it's easy enough in modern C++ to ensure that raw pointers aren't ever owning pointers (edit: outside the limited scope of the implementations of small raii wrappers) and then just read
T*as an observer without adding a more verbose spelling for it. Even when interfacing with third party libraries, I'd read the documentation once and then wrap owning things in smart pointers if necessary (e.g.using window_ptr = unique_ptr<GLFWwindow, delete_with<glfwDestroyWindow>>).3
u/AnyPhotograph7804 22h ago
Yes. But this applies to your code. In a company with old code bases, you will face code, which was written by a person, who is retired 15 years ago. And then, if you see a
char*then have fun to figure out what it really is and who is responsible for its cleanup. And this was the purpose ofexperimantal::observer_ptrto add more context.2
u/ts826848 2d ago
P1408 "Abandon observer_ptr" or a different one?
1
u/ABlockInTheChain 1d ago
Using both an owner and a non-owner (possibly called observer) alias could facilitate a transition as mentioned in "benefits."
T&: non-owning, not null, not rebindable
T*: unknown ownership, may be null, rebindable
std::span<T, 1>: non-owning, not null, rebindableI can't recall ever seeing a use of
std::span<T, 1>but it seems like it has a beneficial use case.2
u/Syracuss graphics engineer/games industry 1d ago
I can't recall ever seeing a use of std::span<T, 1> but it seems like it has a beneficial use case.
std::span<T, 1>exists for the same reasonstd::array<T, 1>exists, for generic programming. Having to write checks and alternative implementations to deal with just a 1 sized span would be annoying.I wouldn't use it to replace non owning and rebindable when
T*serves that function already in all modern codebases I've worked in. It would be massively confusing to see a span used for that as well. You're better off with ausingstatement if you really want to give it an obvious name in the code.If it could be null outside of a span, it could still be null inside. That's really up to your coding practices to guard against.
3
u/ABlockInTheChain 1d ago
If it could be null outside of a span, it could still be null inside. That's really up to your coding practices to guard against.
A function which accepts
std::span<T, 1>as an argument type will not check that argument for null because it's not possible to perform the check. The type itself conveys the invariants and the only way the invariants could have been broken was to deliberately invoke undefined behavior.
T*has no invariant so local coding practices are the only way to know how to interpret it.
T&is still a better argument type for observing, but in any case where you have some compelling reason to take a non-owningT*instead ofT&thenstd::span<T, 1>would be better.0
u/Syracuss graphics engineer/games industry 1d ago edited 1d ago
I see how you're intending to use it now. It's bordering on "too clever". I'd flag it in a code review as it's a non-obvious usage of
std::spanand will definitely trip people up, but if you're going to use it like that why not just usestd::ref/std::reference_wrapper? At least with that one the expected usage is easily visible in a code review.edit: Your usage of span also makes it unnecessarily verbose to construct these spans. You can add some deduction guides or helpers, but still think
std::reference_wrapperis a better fit as it does support the proper operations out of the box.1
u/ABlockInTheChain 1d ago
You can add some deduction guides or helpers
I have functions that take
std::span<T, std::dynamic_extent>arguments, and a helper template function which will construct astd::span<T, 1>from a T& so that a single function overload can handle any number of input objects.No functions which take
std::span<T, 1>though.2
u/Syracuss graphics engineer/games industry 1d ago
If you're using
dynamic_extent, then I don't see how your use case is related toobserver_ptr. I'm so confused why you brought upstd::span<T, 1>in this thread's context. But fair enough, if you need a variable sized span, then you should use span.1
u/ABlockInTheChain 1d ago
This thread made me realize that the
std::span<T, 1>which I am incidentally creating for other purposes contains semantic information that makes relevant to the use case ofobserver_ptr.1
u/germandiago 1d ago
Related but not same: generic programming and void specializations...
I usually use std::monostate and get away with unnecessary, improductive duplications.
3
u/selvakumarjawahar 1d ago
This one: https://arxiv.org/abs/2510.08969. This paper, along with his presentation on this topic last year, motivated me to learn concepts more deeply and apply them in my code. So definitely not nonsense or of no value.
45
u/praesentibus 2d ago
Of all the paper tigers, profiles are the most paper tiger there is.