CppCon 2023 Undefined Behavior in C++: What Every Programmer Should Know and Fear -- Fedor Pikus

pikus-undefinedbehavior.pngRegistration is now open for CppCon 2024! The conference starts on September 15 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting videos of some of the top-rated talks from last year's conference. Here’s another CppCon talk video we hope you will enjoy – and why not register today for CppCon 2024!

Undefined Behavior in C++: What Every Programmer Should Know and Fear

by Fedor Pikus

Summary of the talk:

This talk is about You-Know-What, the thing in our programs we don’t mention by name.

What is this undefined behavior every C++ programmer has grown to fear? Just as importantly, what it isn’t? If it’s so scary, why is it allowed to exist in the language?
The aim of this talk is to approach undefined behavior rationally: without fear but with due caution. We will learn why the standard allows undefined behavior in the first place, what actually happens when a program does something the standard calls “undefined,” and why it must be taken seriously even when the program “works as-is.” As this is a practical talk, we will have live demos of programs with undefined behavior and sometimes unexpected outcomes (if you are very lucky, you might see demons fly out of the speaker’s nose). Also, as this is a practical talk, we will learn how to detect undefined behavior in one’s programs, and how to take advantage of the undefined behavior to gain better performance.

Concurrency: From Theory to Practice -- Lucian Radu Teodorescu

concurrencyteodorescu.pngConcurrency is a complicated topic. Lucian Radu Teodorescu provides a simple theory of concurrency which is easy to reason about and apply.

Concurrency: From Theory to Practice

by Lucian Radu Teodorescu

From the article:

One of the big challenges with concurrency is the misalignment between theory and practice. This includes the goals of concurrency (e.g., improving the performance of the application) and the means we use to achieve that goal (e.g., blocking primitives that slow down the program). The theory of concurrency is simple and elegant. In practice, concurrency is often messy and strays from the good practices of enabling local reasoning and using structured programming.

We present a concurrency model that starts from the theory of concurrency, enables local reasoning, and adheres to the ideas of structured programming. We show that the model can be put into practice and that it yields good results.

Most of the ideas presented here are implemented in a C++ library called concore2full [concore2full]. The library is still a work in progress. The original goal for this model and for this library was its inclusion in the Hylo programming language [Hylo]. For Hylo, we want a concurrency model that allows local reasoning and adheres to the structured programming paradigm. We also wanted a model in which there is no function colouring [Nystrom15], in which concurrency doesn’t require a different programming paradigm.

This article is based on a talk I gave at the ACCU 2024 conference [Teodorescu24]. The conference was great! The programme selection was great; there was always something of interest to me. With many passionate C++ engineers and speakers, the exchange of information between participants was excellent; as they say, the best track was the hallway track. I highly encourage all C++ enthusiasts (and not just C++) to participate in future ACCU conferences.

CppCon 2023 Thread Safety With synchronized_value in C++ -- Jørgen Fogh

Fogh-threadsafety.pngRegistration is now open for CppCon 2024! The conference starts on September 15 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting videos of some of the top-rated talks from last year's conference. Here’s another CppCon talk video we hope you will enjoy – and why not register today for CppCon 2024!

Lightning Talk: Thread Safety With synchronized_value in C++

by Jørgen Fogh

Summary of the talk:

Adding thread safety to existing code is hard. The proposed type synchronized_value makes it less hard.
I will show you why.

CppCon 2023 The Responsibility of C++ -- Neil Henderson

Henderson-responsibility.pngRegistration is now open for CppCon 2024! The conference starts on September 15 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting videos of some of the top-rated talks from last year's conference. Here’s another CppCon talk video we hope you will enjoy – and why not register today for CppCon 2024!

Lightning Talk: The Responsibility of C++ 

by Neil Henderson

Summary of the talk:

Hopefully an amusing and light-hearted look at C++ and its strengths and responsibilities in the software world from a recent life-changing experience.

Fat API Bindings of C++ Objects into Scripting Languages -- Russell K. Standish

fatstandish.pngHow do you expose a C++ object to a TypeScript layer or other scripting language? Russell K. Standish demonstrates an approach using a RESTService API that is scripting-language independent.

Fat API Bindings of C++ Objects into Scripting Languages

by Russell K. Standish

From the article:

fat API exposes nearly all of a C++ object’s public attributes and methods to a consuming environment, such as a scripting language, or web client. This can be contrasted with a conventional, or thin API, where the API is defined up front, and the C++ object provides the implementation, most of which is private to the C++ layer.

Obviously, reflection is required to expose C++ objects to a consuming layer like this – this paper explores using the Classdesc system to implement reflection of C++ objects into a JavaScript/TypeScript environment via a REST service, and also via a Node.js API module.

2024-07 Mailing Available

The 2024-07 mailing of new standards papers is now available.

 

WG21 Number Title Author Document Date Mailing Date Previous Version Subgroup
N4984 WG21 June 2024 Admin Minutes of Meeting Nina Ranns 2024-06-17 2024-07   All of WG21
N4985 WG21 2024-06 St Louis Minutes of Meeting Nina Ranns 2024-07-11 2024-07   All of WG21
N4986 Working Draft, Programming Languages -- C++ Thomas Köppe 2024-07-16 2024-07   All of WG21
N4987 Editors' Report, Programming Languages -- C++ Thomas Köppe 2024-07-16 2024-07   All of WG21
P0260R10 C++ Concurrent Queues Detlef Vollmann 2024-06-27 2024-07 P0260R9 LEWG Library Evolution
P0472R1 Put std::monostate in <utility> David Sankel 2024-06-05 2024-07 P0472R0 LEWG Library Evolution
P0843R13 inplace_vector Gonzalo Brito Gadeschi 2024-06-17 2024-07 P0843R12 LEWG Library Evolution,LWG Library
P0843R14 inplace_vector Gonzalo Brito Gadeschi 2024-06-26 2024-07 P0843R13 LWG Library
P0876R17 fiber_context - fibers without scheduler Oliver Kowalke 2024-07-03 2024-07 P0876R16 EWG Evolution,CWG Core,LWG Library
P0963R3 Structured binding declaration as a condition Zhihao Yuan 2024-06-28 2024-07 P0963R2 CWG Core
P1928R10 std::simd - Merge data-parallel types from the Parallelism TS 2 Matthias Kretz 2024-06-28 2024-07 P1928R9 LWG Library
P1928R11 std::simd - Merge data-parallel types from the Parallelism TS 2 Matthias Kretz 2024-07-16 2024-07 P1928R10 LWG Library
P2075R6 Philox as an extension of the C++ RNG engines Ilya Burylov 2024-06-28 2024-07 P2075R5 LWG Library
P2300R10 `std::execution` Eric Niebler 2024-06-28 2024-07 P2300R9 LEWG Library Evolution,LWG Library
P2319R0 Prevent path presentation problems Victor Zverovich 2024-07-06 2024-07   SG16 Unicode
P2389R2 `dextents` Index Type Parameter Bryce Adelstein Lelbach 2024-06-24 2024-07 P2389R1 LEWG Library Evolution
P2422R1 Remove nodiscard annotations from the standard library specification Ville Voutilainen 2024-06-28 2024-07 P2422R0 LEWG Library Evolution,LWG Library
P2642R6 Padded mdspan layouts Christian Trott 2024-06-18 2024-07 P2642R5 LEWG Library Evolution,LWG Library
P2656R3 C++ Ecosystem International Standard René Ferdinand Rivera Morell 2024-07-11 2024-07 P2656R2 EWG Evolution,LEWG Library Evolution
P2664R7 Proposal to extend std::simd with permutation API Daniel Towner 2024-06-25 2024-07 P2664R6 SG1 Concurrency and Parallelism,LEWG Library Evolution
P2686R4 constexpr structured bindings and references to constexpr variables Corentin Jabot 2024-07-05 2024-07 P2686R3 EWG Evolution,LEWG Library Evolution,CWG Core
P2761R2 Slides: Evaluating structured binding as a condition (P0963R2 presentation) Zhihao Yuan 2024-06-13 2024-07 P2761R1 EWG Evolution
P2761R3 Slides: Structured binding declaration as a condition (P0963R2 presentation) Zhihao Yuan 2024-06-26 2024-07 P2761R2 EWG Evolution
P2769R2 get_element customization point object Ruslan Arutyunyan 2024-06-25 2024-07 P2769R1 SG9 Ranges,LEWG Library Evolution
P2848R1 std::is_uniqued Arthur O'Dwyer 2024-07-14 2024-07 P2848R0 LEWG Library Evolution
P2863R6 Review Annex D for C++26 Alisdair Meredith 2024-06-23 2024-07 P2863R5 EWG Evolution,LEWG Library Evolution
P2863R7 Review Annex D for C++26 Alisdair Meredith 2024-07-09 2024-07 P2863R6 SG22 Compatibility,EWG Evolution,LEWG Library Evolution
P2865R5 Remove Deprecated Array Comparisons from C++26 Alisdair Meredith 2024-07-09 2024-07 P2865R4 SG22 Compatibility
P2866R3 Remove Deprecated Volatile Features From C++26 Alisdair Meredith 2024-06-28 2024-07 P2866R2 CWG Core,LWG Library
P2866R4 Remove Deprecated Volatile Features From C++26 Alisdair Meredith 2024-07-15 2024-07 P2866R3 SG22 Compatibility,CWG Core,LWG Library
P2873R2 Remove Deprecated locale category facets for Unicode from C++26 Alisdair Meredith 2024-07-06 2024-07 P2873R1 LEWG Library Evolution
P2897R2 aligned_accessor: An mdspan accessor expressing pointer overalignment Mark Hoemmen 2024-07-12 2024-07 P2897R1 LEWG Library Evolution
P2897R3 aligned_accessor: An mdspan accessor expressing pointer overalignment Mark Hoemmen 2024-07-15 2024-07 P2897R2 LEWG Library Evolution,LWG Library
P2963R3 Ordering of constraints involving fold expressions Corentin Jabot 2024-06-28 2024-07 P2963R2 CWG Core
P2989R2 A Simple Approach to Universal Template Parameters Corentin Jabot 2024-06-16 2024-07 P2989R1 EWG Evolution
P2996R4 Reflection for C++26 Barry Revzin 2024-06-26 2024-07 P2996R3 EWG Evolution
P3006R1 Launder less Antony Polukhin 2024-07-11 2024-07 P3006R0 SG12 Undefined and Unspecified Behavior,EWG Evolution,CWG Core
P3037R2 constexpr std::shared_ptr Paul Keir 2024-05-24 2024-07 P3037R1 LEWG Library Evolution
P3044R1 sub-string_view from string Michael Florian Hava 2024-07-15 2024-07 P3044R0 LEWG Library Evolution
P3051R2 Structured Response Files René Ferdinand Rivera Morell 2024-07-11 2024-07 P3051R1 EWG Evolution,LEWG Library Evolution
P3064R2 How to Avoid OOTA Without Really Trying Paul E. McKenney 2024-07-12 2024-07 P3064R1 SG1 Concurrency and Parallelism
P3068R3 Allowing exception throwing in constant-evaluation Hana Dusíková 2024-06-27 2024-07 P3068R2 EWG Evolution,LEWG Library Evolution
P3085R3 `noexcept` policy for SD-9 (throws nothing) Ben Craig 2024-07-04 2024-07 P3085R2 LEWG Library Evolution
P3087R1 Make direct-initialization for enumeration types at least as permissive as direct-list-initializatio Jan Schultke 2024-05-29 2024-07 P3087R0 EWG Evolution
P3094R3 std::basic_fixed_string Mateusz Pusz 2024-06-30 2024-07 P3094R2 SG16 Unicode,LEWG Library Evolution
P3096R2 Function Parameter Reflection in Reflection for C++26 Adam Lach 2024-07-16 2024-07 P3096R1 EWG Evolution,LEWG Library Evolution
P3124R0 2024-02 Library Evolution Poll Outcomes   2024-06-14 2024-07   LEWG Library Evolution
P3137R2 views::to_input Tim Song 2024-07-16 2024-07 P3137R1 LEWG Library Evolution
P3138R2 views::cache_last Tim Song 2024-07-16 2024-07 P3138R1 LEWG Library Evolution
P3144R1 Deprecate Delete of Incomplete Class Type Alisdair Meredith 2024-05-23 2024-07 P3144R0 CWG Core
P3144R2 Deleting a Pointer to an Incomplete Type Should be Ill-formed Alisdair Meredith 2024-06-25 2024-07 P3144R1 CWG Core
P3149R4 async_scope -- Creating scopes for non-sequential concurrency Ian Petersen 2024-06-23 2024-07 P3149R3 SG1 Concurrency and Parallelism,LEWG Library Evolution
P3149R5 async_scope -- Creating scopes for non-sequential concurrency Ian Petersen 2024-06-25 2024-07 P3149R4 LEWG Library Evolution
P3161R2 Unified integer overflow arithmetic Tiago Freire 2024-07-15 2024-07 P3161R1 SG6 Numerics
P3164R1 Improving diagnostics for sender expressions Eric Niebler 2024-06-15 2024-07 P3164R0 LEWG Library Evolution
P3164R2 Improving diagnostics for sender expressions Eric Niebler 2024-06-24 2024-07 P3164R1 LEWG Library Evolution
P3168R2 Give std::optional Range Support David Sankel 2024-06-25 2024-07 P3168R1 LEWG Library Evolution
P3175R3 Reconsidering the `std::execution::on` algorithm Eric Niebler 2024-06-24 2024-07 P3175R2 LEWG Library Evolution
P3178R0 Retrieval of Exception Information TPK Healy 2024-05-23 2024-07   LEWGI SG18: LEWG Incubator
P3178R1 Retrieval of Exception Information TPK Healy 2024-05-30 2024-07 P3178R0 LEWGI SG18: LEWG Incubator
P3179R2 C++ parallel range algorithms Ruslan Arutyunyan 2024-06-25 2024-07 P3179R1 SG1 Concurrency and Parallelism,SG9 Ranges
P3182R1 Add container pop methods that return the popped value Brian Bi 2024-07-16 2024-07 P3182R0 LEWG Library Evolution
P3212R0 The contract of sort() Andrzej Krzemieński 2024-07-03 2024-07   SG21 Contracts,EWG Evolution,LEWG Library Evolution
P3223R1 Making std::istream::ignore less surprising Jonathan Wakely 2024-07-03 2024-07 P3223R0 LEWG Library Evolution
P3235R1 std::print more types faster with less memory Victor Zverovich 2024-06-15 2024-07 P3235R0 LEWG Library Evolution
P3235R2 std::print more types faster with less memory Victor Zverovich 2024-06-25 2024-07 P3235R1 LWG Library
P3235R3 std::print more types faster with less memory Victor Zverovich 2024-06-26 2024-07 P3235R2 LWG Library
P3245R1 Allow `[[nodiscard]]` in type alias declarations Xavier Bonaventura 2024-07-15 2024-07 P3245R0 EWGI SG17: EWG Incubator
P3248R1 Require [u]intptr_t Gonzalo Brito Gadeschi 2024-06-16 2024-07 P3248R0 SG1 Concurrency and Parallelism,SG22 Compatibility,EWG Evolution,LEWG Library Evolution
P3255R1 Expose whether atomic notifying operations are lock-free Brian Bi 2024-07-16 2024-07 P3255R0 LEWG Library Evolution
P3265R2 Ship Contracts in a TS Ville Voutilainen 2024-05-27 2024-07 P3265R1 EWG Evolution
P3265R3 Ship Contracts in a TS Ville Voutilainen 2024-05-28 2024-07 P3265R2 EWG Evolution
P3288R1 std::elide Thomas P. K. Healy 2024-05-28 2024-07 P3288R0 EWGI SG17: EWG Incubator,LEWGI SG18: LEWG Incubator
P3288R2 std::elide Thomas P. K. Healy 2024-05-29 2024-07 P3288R1 EWGI SG17: EWG Incubator,LEWGI SG18: LEWG Incubator
P3288R3 std::elide Thomas P. K. Healy 2024-06-27 2024-07 P3288R2 EWGI SG17: EWG Incubator,LEWGI SG18: LEWG Incubator
P3290R1 Integrating Existing Assertions With Contracts Joshua Berne 2024-07-12 2024-07 P3290R0 SG21 Contracts,EWG Evolution
P3294R1 Code Injection with Token Sequences Barry Revzin 2024-07-16 2024-07 P3294R0 SG7 Reflection,EWG Evolution
P3296R1 let_with_async_scope Anthony Williams 2024-06-24 2024-07 P3296R0 SG1 Concurrency and Parallelism,LEWG Library Evolution
P3297R1 C++26 Needs Contract Checking Ryan McDougall 2024-06-21 2024-07 P3297R0 SG21 Contracts,SG23 Safety and Security,EWG Evolution
P3303R1 Fixing Lazy Sender Algorithm Customization Eric Niebler 2024-06-24 2024-07 P3303R0 LEWG Library Evolution
P3309R1 constexpr atomic and atomic_ref Hana Dusíková 2024-07-14 2024-07 P3309R0 LEWG Library Evolution
P3310R1 Solving partial ordering issues introduced by P0522R0 Matheus Izvekov 2024-06-21 2024-07 P3310R0 EWG Evolution,CWG Core
P3310R2 Solving partial ordering issues introduced by P0522R0 Matheus Izvekov 2024-06-21 2024-07 P3310R1 EWG Evolution,CWG Core
P3314R0 2024-07 Library Evolution Polls Inbal Levi 2024-07-16 2024-07   LEWG Library Evolution
P3319R1 Add an iota object for simd (and more) Matthias Kretz 2024-06-28 2024-07 P3319R0 LEWG Library Evolution
P3321R0 Contracts Interaction With Tooling Joshua Berne 2024-07-12 2024-07   SG15 Tooling,SG21 Contracts,EWG Evolution
P3323R0 cv-qualified types in atomic and atomic_ref Gonzalo Brito Gadeschi 2024-06-16 2024-07   SG1 Concurrency and Parallelism
P3325R0 A Utility for Creating Execution Environments Eric Niebler 2024-06-13 2024-07   LEWG Library Evolution
P3325R1 A Utility for Creating Execution Environments Eric Niebler 2024-07-13 2024-07 P3325R0 LEWG Library Evolution
P3325R2 A Utility for Creating Execution Environments Eric Niebler 2024-07-16 2024-07 P3325R1 LEWG Library Evolution
P3326R0 favor ease of use Jarrad J. Waterloo 2024-06-13 2024-07   LEWG Library Evolution
P3328R0 Observable Checkpoints During Contract Evaluation Joshua Berne 2024-06-13 2024-07   SG21 Contracts
P3330R0 User-defined Atomic Read-Modify-Write Operations Gonzalo Brito 2024-06-17 2024-07   SG1 Concurrency and Parallelism
P3331R0 Accessing The First and Last Elements in Associative Containers Nikita Sakharin 2024-06-18 2024-07   LEWGI SG18: LEWG Incubator,LEWG Library Evolution,LWG Library
P3332R0 A simpler notation for PM Bjarne Stroustrup 2024-06-18 2024-07   EWG Evolution
P3335R0 Structured Core Options René Ferdinand Rivera Morell 2024-07-11 2024-07   SG15 Tooling
P3336R0 Usage Experience for Contracts with BDE Joshua Berne 2024-06-23 2024-07   SG21 Contracts,EWG Evolution
P3338R0 Observe and ignore semantics in constant evaluation Ville Voutilainen 2024-06-23 2024-07   EWG Evolution
P3339R0 C++ Ecosystem IS Open License René Ferdinand Rivera Morell 2024-06-23 2024-07   All of WG21
P3340R0 A Consistent Grammar for Sequences Alisdair Meredith 2024-06-24 2024-07   CWG Core
P3341R0 C++ Standard Library Ready Issues to be moved in St Louis, Jun. 2024 Jonathan Wakely 2024-06-24 2024-07   All of WG21
P3342R0 Working Draft, Standard for C++ Ecosystem René Ferdinand Rivera Morell 2024-07-11 2024-07   EWG Evolution,LEWG Library Evolution
P3343R0 Contracts - What are we doing here (EWG Presentation) Joshua Berne 2024-06-25 2024-07   EWG Evolution
P3344R0 Virtual Functions on Contracts (EWG - Presentation for P3097) Joshua Berne 2024-06-28 2024-07   EWG Evolution
P3345R0 Core Language Working Group "ready" Issues for the June, 2024 meeting Jens Maurer 2024-06-28 2024-07   CWG Core
P3351R0 views::scan Yihe Li 2024-07-08 2024-07   SG9 Ranges
P3354R0 Slides for P3233R0 Giuseppe D'Angelo 2024-07-09 2024-07   SG12 Undefined and Unspecified Behavior,EWG Evolution
P3355R0 Fix submdspan for C++26 Mark Hoemmen 2024-07-14 2024-07   LEWG Library Evolution
P3356R0 non_invalidating_vector Jarrad J Waterloo 2024-07-13 2024-07   LEWGI SG18: LEWG Incubator,LEWG Library Evolution
P3357R0 NRVO with factory and after_factory TPK Healy 2024-07-15 2024-07   EWGI SG17: EWG Incubator,LEWGI SG18: LEWG Incubator
P3358R0 SARIF for Structured Diagnostics Sy Brand 2024-07-16 2024-07   SG15 Tooling
P3359R0 Slides for P3298R0 - Implicit conversion functions Bengt Gustafsson 2024-07-15 2024-07   EWGI SG17: EWG Incubator,EWG Evolution
P3360R0 Slides for P3312R0 - Overload Set Types Bengt Gustafsson 2024-07-15 2024-07   EWGI SG17: EWG Incubator

CppCon 2023 std::linalg: Linear Algebra Coming to Standard C++ -- Mark Hoemmen

hoemmen-stdlinalg.pngRegistration is now open for CppCon 2024! The conference starts on September 15 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting videos of some of the top-rated talks from last year's conference. Here’s another CppCon talk video we hope you will enjoy – and why not register today for CppCon 2024!

CppCon 2023 std::linalg: Linear Algebra Coming to Standard C++

by Mark Hoemmen

Summary of the talk:

Many fields depend on linear algebra computations, which include matrix-matrix and matrix-vector multiplies, triangular solves, dot products, and norms. It's hard to implement these fast and accurately for all kinds of number types and data layouts. Wouldn't it be nice if C++ had a built-in library for doing that? Wouldn't it be even nicer if this library used C++ idioms instead of what developers have to do now, which is write nonportable, unsafe, verbose code for calling into an optimized Fortran or C library?

The std::linalg library does just that. It uses the new C++23 feature mdspan to represent matrices and vectors. The library builds on the long history and solid theoretical foundation of the BLAS (Basic Linear Algebra Subroutines), a standard C and Fortran interface with many optimized implementations. The C++ Standard Committee is currently reviewing std::linalg for C++26. The library already has two implementations that work with C++17 or newer compilers, and can take advantage of vendor-specific optimizations. Developers will see how std::linalg can make their C++ safer and more concise without sacrificing performance for use cases that existing BLAS libraries already optimize, while opening up new use cases and potential optimizations.

CppCon 2023 Spanny: Abusing C++ mdspan Is Within Arm’s Reach -- Griswald Brooks

brooks-spanny.pngRegistration is now open for CppCon 2024! The conference starts on September 15 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting videos of some of the top-rated talks from last year's conference. Here’s another CppCon talk video we hope you will enjoy – and why not register today for CppCon 2024!

Lightning Talk: Spanny: Abusing C++ mdspan Is Within Arm’s Reach

by Griswald Brooks

Summary of the talk:

mdspan introduced in C++23 gave us a standard multidimensional way to view into a container of data. While the canonical use case is to refer to a stack or heap allocated data, the accessor policy allows you to inject any side effect allowing the data to come from anywhere... like a robot arm inspecting bins.

User-Defined Formatting in std::format – Part 2 -- Spencer Collyer

logo.pngLast time, we saw how to provide formatting for a simple user-defined class. Spencer Collyer builds on this, showing how to write a formatter for more complicated types.

User-Defined Formatting in std::format – Part 2

by Spencer Collyer

From the article:

In the previous article in this series [Collyer24], I showed how to write a class to format user-defined classes using the std::format library. In this article I will describe how this can be extended to container classes or any other class that holds objects whose type is specified by the user of your class.

A note on the code listings: The code listings in this article have lines labelled with comments like // 1. Where these lines are referred to in the text of this article, it will be as ‘line 1’ for instance, rather than ‘the line labelled // 1’.

Nested formatter objects

The objects created from the formatter template structs are just ordinary C++ objects – there is nothing special about them 1. In particular, there is nothing to stop you including an object of a formatter template type inside one of your user-defined formatter structs.

You might wonder why you would want to do that. One simple case is if you have a templated container class, and want to create a formatter that can output the container in one go, rather than having to write code to iterate over the container and output each value in turn. Having a nested formatter for the contained value type allows you to do this and allow the values to be formatted differently to the default, as the following examples will show. Other uses will no doubt come to mind for your own classes.

Qt and Trivial Relocation (Part 4) -- Giuseppe D'Angelo

dangeloqt.pngThe conclusion of the last post was that we need to change something in our models: maybe std::vector should use a different strategy when erasing elements; maybe types like std::tuple<int &> should not be allowed to be stored in a vector; maybe Qt should not be using memmove when erasing objects of trivially relocatable type (but it can still optimize the reallocation of a vector); maybe Qt’s definition of trivial relocability does not match ours, and we need to fix our definitions. In this post we will explore these possibilities and reach some conclusions.

Qt and Trivial Relocation (Part 4)

by Giuseppe D'Angelo

From the article:

As we have already discussed in the previous blog posts, it is possible to implement erasure in a number of ways, which are not equivalent. The Standard Library chose a specific implementation strategy (move-assign the elements after the ones to be destroyed to the left; destroy the moved-from last elements). Changing it now, over 26 years after the fact, sounds extremely scary; std::vector is such a central class that surely such a change would break somebody’s code.

That doesn’t mean that we can’t at least reason about a possible change there!

Also, there is another library that we keep talking about in these blog posts. This other library has a much smaller userbase than the Standard Library, and that has fewer regards with breaking backwards compatibility. We should certainly reason about that library as well. I’m talking about Qt, of course ��