AMA with Herb Sutter - Meeting C++ live
Meeting C++ hosted an online AMA with Herb Sutter on Friday.
AMA with Herb Sutter - Meeting C++ live
by Jens Weller & Herb Sutter
Video:
October 25, Pavia, Italy
November 6-8, Berlin, Germany
November 3-8, Kona, HI, USA
By Meeting C++ | Oct 12, 2024 05:56 AM | Tags: meetingcpp community c++26 c++23 c++20 basics advanced
Meeting C++ hosted an online AMA with Herb Sutter on Friday.
AMA with Herb Sutter - Meeting C++ live
by Jens Weller & Herb Sutter
Video:
By Blog Staff | Oct 11, 2024 10:06 AM | Tags: None
When working with C++ standard containers and functions, handling references can sometimes lead to unexpected behavior, particularly with copy semantics. This is where
std::ref and std::cref come into play, allowing you to store references in containers and pass them safely to template functions like std::bind or std::thread.
What is std::ref?
by Sandor Dargo
From the article:
Have you heard about
std::refandstd::cref? The helper functions that generate objects of typestd::reference_wrapper? The answer is probably yes. In that case, this article is probably not for you. But if you haven’t heard about them, or the only usage ofstd::reference_wrapperyou faced was storing references in a vector, then probably it’s worth reading on.This article is inspired by some failing tests that needed me to use
std::refin order to pass them.What does
reference_wrapperdo?A reference of an object
T(T&) is not copy assignable. On the other hand,std::reference_wrapper<T>which emulatesT&it both copy-constructible and copy-assignable. It’s even trivially copyable, so copying can take place on a byte level which makes it very efficient.So when should we use such a wrapper?
By Meeting C++ | Oct 9, 2024 10:59 AM | Tags: meetingcpp learning event community c++26 c++23 c++20
A post highlighting some of the talks that let you learn about Modern C++ at Meeting C++ 2024
Learn Modern C++ at Meeting C++ 2024
by Jens Weller
From the article:
I think this is what should you get excited the most, C++20 is making its way through the compiler implementations and you actually can apply this to your own code base. The top voted talk this year reflects this, in C++ Modules - getting started today Andreas Weis will show you how Modules are now available with the big 3 compilers.
...
Trainings at Meeting C++
After Meeting C++ 2024 there is a trainings week in the last week of November, you an choose between trainings from Kevlin Henney, Slobodan Dimtrovic and Nicolai Josuttis:
Programming with Guts by Kevlin Henney
C++ for C Developers - Migrating from C to C++ by Slobodan Dimtrovic
Generic programming in C++ with templates and auto by Nico Josuttis
Concepts, Ranges, and Views - The New Way of Programming in C++ by Nico Josuttis
By Blog Staff | Oct 8, 2024 12:37 PM | Tags: None
When designing a circular doubly-linked list, the initial challenge is determining how to manage the construction of new nodes in relation to existing ones. While constructors seem like a natural fit for placing nodes before or after a given node, overloading them can lead to ambiguity and poor design choices. Instead, using distinct tag types or factory methods provides clearer intent, ensuring flexibility while respecting the constraints of guaranteed copy elision for node addresses.
Constructing Nodes of a Hand-made Linked List, How Hard Can it Be?
by Raymond Chen
From the article:
Suppose you are writing your own circular doubly-linked list structure.
struct node { node* prev; node* next; };A natural choice for the default constructor is to make the node the sole element of a circular doubly-linked list.
struct node { node* prev = this; node* next = this; };What if you also want to add a node after an existing node? Well, we could add a constructor for that.
struct node { node* prev = this; node* next = this; node() = default; // Construct a node after a specific node node(node* other) : prev(other), next(other->next) { prev->next = this; next->prev = this; } };(Note that the “construct after another node” constructor takes the other
nodeby pointer, rather than by reference, so that it won’t be mistaken for a copy constructor.)But maybe you also want to have a “before” constructor that inserts the new node before an existing node...
By Blog Staff | Oct 3, 2024 12:16 PM | Tags: None
Previously, I tried to answer the question: what’s so hard about constexpr allocation?. Today, we continue what will become a series of posts about attempting to explain the issues behind a bunch of hard problems we’re trying to solve. The next problem: class types as non-type template parameters.
What's So Hard About Class Types as Non-type Template Parameters?
by Barry Revzin
From the article:
Before C++20, the only types you could use as non-type template parameters were scalar types (like
intandenums, but not floating point), pointers (including pointers-to-members), and references. Notably, not class types.Floating point types were also added in C++20.
The hard question about handling class types is: how do you determine template argument equivalence? Class types can define their own equality. But you don’t really want to rely on that, since now matching specializations becomes a quadratic problem — you can’t really do much when determining the instantiation for some template
f<x>other than looping through every other valuevito see ifx == vi.The other problem is we need
==to really be strong enough. One very easy problem to run into in this space is violating the One Definition Rule (ODR). One essential, core requirement for templates is that instantiating the same template with the same arguments has to yield the same code.
By Meeting C++ | Oct 1, 2024 03:38 AM | Tags: meetingcpp community
Meeting C++ offers free online and onsite tickets through their student and support programs. This is supported through the ticket sales for Meeting C++ 2024.
Highlighting the student and support tickets for Meeting C++ 2024
by Jens Weller
From the article:
Like every year, I'd like to point towards the programs for those that can't afford to pay for a ticket for Meeting C++ 2024.
And let me start with thanking those that enable these programs through their ticket buying: the attendees and sponsors of Meeting C++ 2024! With the schedule published, I'd like to highlight the student and support tickets for Meeting C++ 2024. For a few years now Meeting C++ has hosted programs to give students, underrepresented folks and those who can't afford a ticket access to the conference.
This year for the first time you can choose to register either for onsite or online for these programs. A limited amount of tickets for Berlin will be available, depending on the ticket sale in October. So incase you registered for onsite but are not chosen for a ticket, then you'll have a chance to an online ticket...
By Blog Staff | Sep 30, 2024 03:10 PM | Tags: None
C++ On Sea took place in Folkestone again in February this year. Sandor Dargo shares an overview of his favourite talks and some emergent ideas.
Trip report: C++ On Sea 2024
by Sandor Dargo
From the article:
Last week, between the 3rd and 5th of July, I had the privilege of attending and presenting at C++ on Sea 2024 [CPPoS-1] for the 5th time in a row! I’m grateful that the organizers accepted me not simply as a speaker, but that they granted me a double slot to deliver a half-day workshop about how to reduce the size of a binary. I’m also thankful for my management that they gave me the time to go to Folkestone and share our knowledge on binary size. Last but not least, great thanks goes to my wife, who took care of the kids alone that week.
Let me share with you a few thoughts about the conference.
First, I’m going to write about the 3 talks that I liked the most during the 3 days, then I’m going to share 3 interesting ideas I heard about and then I’m going to share some personal impressions about the conference.
By Meeting C++ | Sep 28, 2024 06:44 AM | Tags: poco meetingcpp iot embedded community
Recently Günter Obiltschnig from the POCO Project gave a talk about IoT Development with POCO C++ libraries and macchinaio at a by macchina.io sponsored Meetup of Meeting C++ online.
IoT Development with POCO C++ libraries and macchinaio
by Günter Obiltschnig
Chapter Videos:
Projects using POCO C++ Libaries and macchina.io in the real world
By Blog Staff | Sep 26, 2024 03:06 PM | Tags: None
Atomics form a relatively low level, but fundamental part of sharing data across threads. Lucian Radu Teodorescu reminds us what atomics are and how and when to use them.
In an Atomic World
by Lucian Radu Teodorescu
From the article:
We often discuss mutexes as the basic building blocks of concurrency. However, there are more fundamental concepts upon which concurrent programs and synchronization primitives are constructed. The C++ language defines a memory model, which describes how programs behave when multiple threads are involved. Additionally, C++ introduces atomic operations that serve as foundation for working with data across threads, ensuring both safety and performance. The goal of C++ atomics is to closely align with the hardware and eliminate the need for lower-level operations that must work across threads.
The topic of atomics is often overlooked, and the prevailing advice is to avoid them. While this advice is generally sound, there are occasions when we need to use atomics to fully leverage the language’s capabilities. This article aims to give atomics the attention they deserve, as they have yet to be featured in an Overload article.
The subject of atomics is extensive. For a comprehensive exploration, readers are encouraged to consult books by Anthony Williams [Williams19] and Mara Bos [Bos23]. While the Bos book primarily focuses on Rust, there is still much to be learned about atomics for C++ programmers. The reader can also consider cppreference.com for a quick reference to the atomics library [cppreference-1] In this article, we will examine various memory ordering models and illustrate their usage through simplified practical examples.
By Administrator | Sep 25, 2024 09:33 PM | Tags: None
The 2024-09 mailing of new standards papers is now available.
| WG21 Number | Title | Author | Document Date | Mailing Date | Previous Version | Subgroup |
|---|---|---|---|---|---|---|
| N4990 | Business Plan and Convener's Report | Herb Sutter | 2024-08-26 | 2024-09 | All of WG21 | |
| P0472R2 | Put std::monostate in <utility> | David Sankel | 2024-09-09 | 2024-09 | P0472R1 | LEWG Library Evolution |
| P1030R7 | std::filesystem::path_view | Niall Douglas | 2024-09-06 | 2024-09 | P1030R6 | LEWG Library Evolution |
| P1061R9 | Structured Bindings can introduce a Pack | Barry Revzin | 2024-08-24 | 2024-09 | P1061R8 | CWG Core |
| P2019R7 | Thread attributes | Corentin Jabot | 2024-09-16 | 2024-09 | P2019R6 | LWG Library |
| P2287R3 | Designated-initializers for base classes | Barry Revzin | 2024-09-09 | 2024-09 | P2287R2 | EWG Evolution |
| P2319R1 | Prevent path presentation problems | Victor Zverovich | 2024-09-14 | 2024-09 | P2319R0 | LEWG Library Evolution |
| P2688R2 | Pattern Matching: `match` Expression | Michael Park | 2024-09-17 | 2024-09 | P2688R1 | EWG Evolution |
| P2786R7 | Trivial Relocatability For C++26 | Mungo Gill | 2024-09-17 | 2024-09 | P2786R6 | EWG Evolution,LEWG Library Evolution |
| P2835R5 | Expose std::atomic_ref's object address | Gonzalo Brito Gadeschi | 2024-09-02 | 2024-09 | P2835R4 | LEWG Library Evolution |
| P2835R6 | Expose std::atomic_ref's object address | Gonzalo Brito Gadeschi | 2024-09-03 | 2024-09 | P2835R5 | LEWG Library Evolution,LWG Library |
| P2841R4 | Concept and variable-template template-parameters | Corentin Jabot | 2024-09-14 | 2024-09 | P2841R3 | CWG Core |
| P2846R3 | reserve_hint: Eagerly reserving memory for not-quite-sized lazy ranges | Corentin Jabot | 2024-09-14 | 2024-09 | P2846R2 | LEWG Library Evolution |
| P2879R0 | Proposal of std::dump | Andrew Tomazos | 2024-09-17 | 2024-09 | LEWGI SG18: LEWG Incubator,SG20 Education | |
| P2945R1 | Additional format specifiers for time_point | Barry Revzin | 2024-09-09 | 2024-09 | P2945R0 | LEWG Library Evolution |
| P2988R7 | std::optional<T&> | Steve Downey | 2024-09-10 | 2024-09 | P2988R6 | LEWG Library Evolution,LWG Library |
| P3016R4 | Resolve inconsistencies in begin/end for valarray and braced initializer lists | Arthur O'Dwyer | 2024-09-14 | 2024-09 | P3016R3 | LWG Library |
| P3019R9 | Vocabulary Types for Composite Class Design | Jonathan Coe | 2024-09-15 | 2024-09 | P3019R8 | LEWG Library Evolution,LWG Library |
| P3037R3 | constexpr std::shared_ptr | Paul Keir | 2024-09-03 | 2024-09 | P3037R2 | LEWG Library Evolution |
| P3074R4 | trivial unions (was std::uninitialized<T>) | Barry Revzin | 2024-09-09 | 2024-09 | P3074R3 | EWG Evolution |
| P3096R3 | Function Parameter Reflection in Reflection for C++26 | Adam Lach | 2024-09-15 | 2024-09 | P3096R2 | EWG Evolution,LEWG Library Evolution |
| P3128R1 | Graph Library: Algorithms | 2024-09-12 | 2024-09 | P3128R0 | SG14 Low Latency,SG19 Machine Learning | |
| P3128R2 | Graph Library: Algorithms | 2024-09-12 | 2024-09 | P3128R1 | SG14 Low Latency,SG19 Machine Learning | |
| P3210R2 | A Postcondition *is* a Pattern Match | Andrew Tomazos | 2024-09-09 | 2024-09 | P3210R1 | SG21 Contracts,EWG Evolution |
| P3245R2 | Allow `[[nodiscard]]` in type alias declarations | Xavier Bonaventura | 2024-09-15 | 2024-09 | P3245R1 | EWGI SG17: EWG Incubator |
| P3248R2 | Require [u]intptr_t | Gonzalo Brito Gadeschi | 2024-09-06 | 2024-09 | P3248R1 | EWG Evolution,LEWG Library Evolution |
| P3290R2 | Integrating Existing Assertions With Contracts | Joshua Berne | 2024-09-06 | 2024-09 | P3290R1 | SG21 Contracts,EWG Evolution |
| P3295R1 | Freestanding constexpr containers and constexpr exception types | Ben Craig | 2024-09-15 | 2024-09 | P3295R0 | LEWG Library Evolution |
| P3299R1 | Range constructors for std::simd | Daniel Towner | 2024-09-16 | 2024-09 | P3299R0 | LEWG Library Evolution |
| P3309R2 | constexpr atomic and atomic_ref | Hana Dusíková | 2024-08-29 | 2024-09 | P3309R1 | LEWG Library Evolution |
| P3335R1 | Structured Core Options | René Ferdinand Rivera Morell | 2024-09-17 | 2024-09 | P3335R0 | SG15 Tooling |
| P3371R1 | Fix C++26 by making the rank-1, rank-2, rank-k, and rank-2k updates consistent with the BLAS | Mark Hoemmen | 2024-09-14 | 2024-09 | P3371R0 | LEWG Library Evolution |
| P3372R1 | constexpr containers and adapters | Hana Dusíková | 2024-09-17 | 2024-09 | P3372R0 | LEWG Library Evolution |
| P3375R0 | Reproducible floating-point results | Guy Davidson | 2024-09-10 | 2024-09 | SG6 Numerics,SG14 Low Latency,LEWG Library Evolution | |
| P3379R0 | Constrain std::expected equality operators | Jonathan Wakely | 2024-08-27 | 2024-09 | LEWG Library Evolution | |
| P3380R0 | Extending support for class types as non-type template parameters | Barry Revzin | 2024-09-09 | 2024-09 | EWG Evolution | |
| P3381R0 | Syntax for Reflection | Barry Revzin | 2024-09-16 | 2024-09 | EWG Evolution | |
| P3382R0 | Coarse clocks and resolutions | Antony Polukhin | 2024-08-28 | 2024-09 | LEWGI SG18: LEWG Incubator,LEWG Library Evolution,LWG Library | |
| P3383R0 | mdspan.at() | Stephan Lachnit | 2024-09-04 | 2024-09 | LEWGI SG18: LEWG Incubator | |
| P3384R0 | __COUNTER__ | Jeremy Rifkin | 2024-09-05 | 2024-09 | EWG Evolution | |
| P3385R0 | Attributes reflection | Aurelien Cassagnes | 2024-09-16 | 2024-09 | SG7 Reflection | |
| P3388R0 | When Do You Know connect Doesn't Throw? | Robert Leahy | 2024-09-10 | 2024-09 | LEWG Library Evolution | |
| P3389R0 | Of Operation States and Their Lifetimes (LEWG Presentation 2024-09-10) | Robert Leahy | 2024-09-10 | 2024-09 | LEWG Library Evolution | |
| P3390R0 | Safe C++ | Sean Baxter | 2024-09-11 | 2024-09 | SG23 Safety and Security | |
| P3391R0 | constexpr std::format | Barry Revzin | 2024-09-12 | 2024-09 | LEWG Library Evolution | |
| P3392R0 | Do not promise support for function syntax of operators | Corentin Jabot | 2024-09-14 | 2024-09 | LEWG Library Evolution | |
| P3396R0 | std::execution wording fixes | Lewis Baker | 2024-09-16 | 2024-09 | LWG Library | |
| P3397R0 | Clarify requirements on extended floating point types | Hans Boehm | 2024-09-16 | 2024-09 | SG6 Numerics | |
| P3398R0 | User specified type decay | Bengt Gustafsson | 2024-09-17 | 2024-09 | EWGI SG17: EWG Incubator | |
| P3401R0 | Enrich Creation Functions for the Pointer-Semantics-Based Polymorphism Library - Proxy | Tian Liao | 2024-09-17 | 2024-09 | LEWGI SG18: LEWG Incubator,LEWG Library Evolution | |
| P3402R0 | A Safety Profile Verifying Class Initialization | Marc-André Laverdière | 2024-09-17 | 2024-09 | SG23 Safety and Security |