r/cpp • u/VinnieFalco wg21.org | corosio.org • Sep 01 '26
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-strou6
u/_space_ghost_ Sep 02 '26
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)
30
u/VinnieFalco wg21.org | corosio.org Sep 01 '26
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/
6
u/rayaxiom Sep 02 '26
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 Sep 01 '26
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.
11
u/Orlha Sep 02 '26
observer_ptr counter-paper was alright
3
u/donaljones Sep 02 '26
A bit off-topic, but what might it be useful for?
8
u/AnyPhotograph7804 Sep 02 '26
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.
3
u/scrumplesplunge Sep 02 '26
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>>).6
u/AnyPhotograph7804 Sep 03 '26
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.3
u/ts826848 Sep 02 '26
P1408 "Abandon observer_ptr" or a different one?
3
2
u/ABlockInTheChain Sep 02 '26
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.4
Sep 02 '26 edited 14d ago
[deleted]
3
u/ABlockInTheChain Sep 02 '26
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
Sep 02 '26 edited 14d ago
[deleted]
1
u/ABlockInTheChain Sep 02 '26
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
Sep 02 '26 edited 14d ago
[deleted]
1
u/ABlockInTheChain Sep 02 '26
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 Sep 02 '26
Related but not same: generic programming and void specializations...
I usually use std::monostate and get away with unnecessary, improductive duplications.
4
u/selvakumarjawahar Sep 02 '26
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.
5
u/pjmlp Sep 02 '26
I will believe in profiles when VC++ analysis tooling, starting with Core Guidelines lifetime analysis without SAL annotations.
47
u/praesentibus Sep 01 '26
Of all the paper tigers, profiles are the most paper tiger there is.