May 2021

How to Insert Several Elements in a Vector (With No Memory Errors)--Jonathan Boccara

How do you do it?

How to Insert Several Elements in a Vector (With No Memory Errors)

by Jonathan Boccara

From the article:

Inserting elements in a vector sounds like the most basic use case we can think of when it comes to using collections in C++.

Nevertheless, this is a complex topic in itself, because std::vector offers various ways to insert several elements. Choosing the most appropriate depending on your exact use case allows to write more expressive code. And misusing the interface of std::vector can lead to memory errors.

Let’s navigate the various ways to insert several elements in a vector in a safe way, so that you can choose the one that fits best for your code...

Compile-time pre-calculations in C++--Mohammad Nasirifar

The evolution.

Compile-time pre-calculations in C++

by Mohammad Nasirifar

From the article:

With C++17’s constexpr functions and C++20’s consteval specifier, it is easy to do io-independent pre-calculations of algorithms while compiling the program. This may not be useful or even possible in long running programs and is unlikely to make a difference in their performance, but in binaries that do short calculations with a set of parameters fixed at compile-time, a Sieve of Eratosthenes array, or roots of unity used for calculating DFT loaded right from the binary could make a difference...

East End Functions--Phil Nash

Did you know about those reasons?

East End Functions

by Phil Nash

From the article:

There has been a recent stirring of attention, in the C++ community, for the practice of always placing the const modifier to the right of the thing it modifies. The practice has even been gifted a catchy name: East Const (which, I think, is what has stirred up the interest)...

2021-05 Mailing Available

The 2021-05 mailing of new standards papers is now available.


WG21 Number Title Author Document Date Mailing Date Previous Version Subgroup
P0009R11 MDSPAN Christian Trott 2021-05-15 2021-05 P0009R10 LWG Library
P0009R12 MDSPAN Christian Trott 2021-05-20 2021-05 P0009R11 LWG Library
P0447R14 Introduction of std::colony to the standard library Matt Bentley 2021-04-20 2021-05 P0447R13 SG14 Low Latency,LEWG Library Evolution,All of WG21
P0493R2 Atomic maximum/minimum Al Grant 2021-05-15 2021-05 P0493R1 SG1 Concurrency and Parallelism,LEWG Library Evolution
P1018R10 C++ Language Evolution status pandemic edition 2021/04 JF Bastien 2021-04-28 2021-05 P1018R9 EWG Evolution,All of WG21
P1068R5 Vector API for random number generation Ilya Burylov 2021-05-14 2021-05 P1068R4 LEWG Library Evolution
P1122R4 Proposed Wording for Concurrent Data Structures: Read-Copy-Update (RCU) Paul E. McKenney 2021-05-14 2021-05 P1122R3 All of WG21
P1328R1 Making std::type_info::operator== constexpr Peter Dimov 2021-05-03 2021-05 P1328R0 LWG Library
P1701R2 Inline Namespaces: Fragility Bites Nathan Sidwell 2021-05-04 2021-05 P1701R1 EWG Evolution
P2013R4 Freestanding Language: Optional ::operator new Ben Craig 2021-05-03 2021-05 P2013R3 CWG Core
P2066R7 Suggested draft TS for C++ Extensions for Minimal Transactional Memory Jens Maurer 2021-05-14 2021-05 P2066R6 LEWG Library Evolution,CWG Core
P2093R6 Formatted output Victor Zverovich 2021-05-13 2021-05 P2093R5 SG16 Unicode,LEWG Library Evolution
P2136R3 invoke_r Zhihao Yuan 2021-04-30 2021-05 P2136R2 LWG Library
P2138R4 Rules of Design<=>Specification engagement Ville Voutilainen 2021-04-19 2021-05 P2138R3 EWG Evolution,LEWG Library Evolution
P2168R3 generator: A Synchronous Coroutine Generator Compatible With Ranges Corentin Jabot 2021-04-19 2021-05 P2168R2 LEWG Library Evolution
P2280R2 Using unknown references in constant expressions Barry Revzin 2021-05-15 2021-05 P2280R1 EWG Evolution
P2291R1 Add Constexpr Modifiers to Functions to_chars and from_chars for Integral Types in Header Daniil Goncharov 2021-05-05 2021-05 P2291R0 LEWG Library Evolution,LWG Library
P2299R1 `mdspan` and CTAD Bryce Adelstein Lelbach 2021-04-19 2021-05 P2299R0 LEWG Library Evolution
P2299R2 `mdspan` and CTAD Bryce Adelstein Lelbach 2021-05-20 2021-05 P2299R1 LEWG Library Evolution
P2303R3 Function literals and value closures Jens Gustedt 2021-05-15 2021-05 P2303R2 SG22 Compatability
P2304R2 Improve type generic programming Jens Gustedt 2021-05-15 2021-05 P2304R1 SG22 Compatability
P2305R3 Type inference for variable definitions and function returns Jens Gustedt 2021-05-15 2021-05 P2305R2 SG22 Compatability
P2306R2 Type-generic lambdas Jens Gustedt 2021-05-15 2021-05 P2306R1 SG22 Compatability
P2307R2 Lvalue closures Jens Gustedt 2021-05-15 2021-05 P2307R1 SG22 Compatability
P2311R1 Make false and true first-class language features Jens Gustedt 2021-05-09 2021-05 P2311R0 SG22 Compatability
P2314R2 Character sets and encodings Jens Maurer 2021-05-14 2021-05 P2314R1 CWG Core,LWG Library
P2325R3 Views should not be required to be default constructible Barry Revzin 2021-05-14 2021-05 P2325R2 LEWG Library Evolution
P2328R1 join_view should join all views of ranges Tim Song 2021-05-08 2021-05 P2328R0 LWG Library
P2334R1 Add support for preprocessing directives elifdef and elifndef Melanie Blower 2021-04-30 2021-05 P2334R0 EWG Evolution,CWG Core
P2351R0 Mark all library static cast wrappers as [[nodiscard]] Hana Dusíková 2021-04-25 2021-05   LEWG Library Evolution
P2367R0 Remove misuses of list-initialization from Clause 24 Tim Song 2021-04-29 2021-05   LWG Library
P2368R0 2020 Winter Library Evolution Polls Bryce Adelstein Lelbach 2021-04-27 2021-05   LEWG Library Evolution
P2371R0 P0798R6: Monadic operations for std::optional Sy Brand 2021-04-27 2021-05   LWG Library
P2372R0 Fixing locale handling in chrono formatters Victor Zverovich 2021-05-03 2021-05   LEWG Library Evolution
P2372R1 Fixing locale handling in chrono formatters Victor Zverovich 2021-05-13 2021-05 P2372R0 LEWG Library Evolution,LWG Library
P2374R0 views::cartesian_product Sy Brand 2021-05-04 2021-05   LEWG Library Evolution
P2374R1 views::cartesian_product Sy Brand 2021-05-11 2021-05 P2374R0 LEWG Library Evolution
P2375R0 Generalisation of nth_element to a range of nths Johan Lundberg 2021-05-15 2021-05   EWG Evolution
P2376R0 Comments on Simple Statistical Functions (p1708r4): Contracts, Exceptions and Special cases Johan Lundberg 2021-05-11 2021-05   SG6 Numerics,SG19 Machine Learning
P2377R0 [[nodiscard]] in the Standard Library: Clause 23 Iterators library Christopher Di Bella 2021-05-14 2021-05   LEWG Library Evolution
P2378R0 Properly define blocks as part of the grammar Jens Gustedt 2021-05-15 2021-05   SG22 Compatability
P2380R0 reference_wrapper Associations Robert Leahy 2021-05-15 2021-05   SG4 Networking
P2381R0 Pattern Matching with Exception Handling Jarrad J. Waterloo 2021-05-15 2021-05   EWG Evolution
P2382R0 Presentation Slides for P2123R0 Hal Finkel 2021-05-15 2021-05   LEWG Library Evolution

PVS-Studio 7.13: Blame Notifier, MISRA

The list of diagnostics supported by MISRA and AUTOSAR continues to grow. We've expanded the Blame Notifier utility's capabilities. The analysis of Ninja projects on Windows has been enhanced and now involves the JSON Compilation Database.

PVS-Studio 7.13

by Andrey Karpov

From the article:

  • The C++ analyzer provides enhanced support of Ninja projects on Windows using JSON Compilation Database (compile_commands.json).
  • The C++ PVS-Studio analyzer spends 10% less time checking source files with the use of the Clang compiler.
  • To check C++ and C# Visual Studio PVS-Studio_Cmd.exe projects, you can pass the suppression file directly. Before this, you could add suppressed warnings only at the projects and solution level.

CopperSpice: Static Things

New video on the CopperSpice YouTube Channel:

Static Things

by Barbara Geller and Ansel Sermersheim

About the video:

In this video we look at some of the places you can use the static keyword, and what it means in these different locations. Is it valid to put a static variable in a header file? Can you use a static constexpr method as a constant expression? Watch our video and find out some of the unusual side effects of static.

Please take a look and remember to subscribe!

C++20 Ranges are complete in Visual Studio 2019 version 16.10--Casey Carter

No reason not to use them.

C++20 Ranges are complete in Visual Studio 2019 version 16.10

by Casey Carter

From the article:

We are proud to announce completion of our implementation of C++20 Ranges in the Standard Library in the VS2019 v16.10 release under/std:c++latest. We announced the first useful user-visible parts of Ranges in VS 2019 v16.6 in mid 2020, the trickle accelerated into a gushing stream, and the final parts are now in place. This represents a huge body of work with input from multiple open-source contributors over the last two years...

Class Templates--Rainer Grimm

The series continue.

Class Templates

by Rainer Grimm

From the article:

A function template represents a family of functions. Accordingly, a class template represents a family of classes. Today, I want to introduce class templates...

Building LLVM in 90 seconds using Amazon Lambda--Nelson Elhage


Building LLVM in 90 seconds using Amazon Lambda

by Nelson Elhage

From the article:

Last week, Frederic Cambus wrote about building LLVM quickly on some very large machines, culminating in a 2m37s build on a 160-core ARM machine.

I don’t have a giant ARM behemoth, but I have been working on a tool I call Llama, which lets you offload computational work – including C and C++ builds – onto Amazon Lambda. I decided to see how good it could do at a similar build...