December 2024

How to Ensure a Class is not Copyable or Movable -- Sandor Dargo

Dargo-classisnotcopyable.pngThe topic of this post is to show different ways to ensure that a class is either non-moveable or non-copyable.

How to Ensure a Class is not Copyable or Movable

by Sandor Dargo

From the article:

If we follow the classification proposed by Sebastian Theophil, we can talk about 4 different class types:

  • value classes
  • container classes
  • resource classes
  • singleton classes

While the first two should be regular classes offering both copy and move semantics, the latter two are different. One shouldn’t be able to copy resources and singletons probably shouldn’t be moveable.

It’s up to us to ensure that a class we create implements the right special member functions (SMFs from now on). And the Hinnant table is here to guide us.

In C++, How Can I Make a Default Parameter be the This Pointer of the Caller? -- Raymond Chen

RaymondChen_5in-150x150.jpgIn C++, associating member objects like properties or events with their containing class often requires passing this redundantly. This article explores a generalized, flexible solution using templates, variadic arguments, and deducing this to streamline ownership initialization without boilerplate.

In C++, How Can I Make a Default Parameter be the This Pointer of the Caller? Revisited

by Raymond Chen

From the article:

Some time ago, we looked at making the default parameter of a method be the this pointer of the caller. The scenario was something like this:

struct Property
{
    Property(char const* name, int initial, Object* owner) :
        m_name(name), m_value(initial), m_owner(owner) {}

    ⟦ other methods elided - use your imagination ⟧

    char const* m_name;
    Object* m_owner;
    int m_value;
};

struct Widget : Object
{
    Property Height{ "Height", 10, this };
    Property Width{ "Width", 10, this };
};

and we didn’t want to have to type this as the last parameter to all the Property constructors. We came up with this:

template<typename D>
struct PropertyHelper
{
    Property Prop(char const* name, int initial)
    { return Property(name, initial, static_cast<D*>(this)); }
};

struct Widget : Object, PropertyHelper<Widget>
{
    Property Height = Prop("Height", 10);
    Property Width = Prop("Width", 10);
};

The Operations for Reading and Writing Single Elements for C++ Standard Library Maps -- Raymond Chen

RaymondChen_5in-150x150.jpgSome time ago, I noted that the std::map subscript operator is an attractive nuisance. It is the most convenient syntax, but is not often what you actually want.

The Operations for Reading and Writing Single Elements for C++ Standard Library Maps

by Raymond Chen

From the article:

I’ve broken down the various std::map lookup and update operations into a table so you can choose the best one for your situation.
2024-11-21_13-35-17.png

In the table above, key is the map key, value is the mapped type, and params are parameters to the mapped type constructor.

Note that insert and the first emplace¹ take a value which is discarded if it turns out that the key already exists. This is undesirable if creating the value is expensive.

One frustrating scenario is the case where the mapped type’s default constructor is not the constructor you want to use for operator[], or if you want the initial mapped value to be the result of a function call rather than a constructor. Here’s something I sort of threw together.

C++ Online 2025 Registration now Open

C++ Online conference and workshop tickets are now available:

C++ Online 2025 Registration Now Open!

by C++ Online

From the article:

We’re excited to announce that ticket sales for C++Online 2025 are officially open! Join us from 26th - 28th February for three days packed with expert talks, networking, and interactive virtual experiences—all from the comfort of your own home.

Trip Report: Fall ISO C++ Meeting in Wrocław, Poland -- Jonathan Müller

Depositphotos_170038592_S.jpgJonathan Müller attended the fall 2024 meeting of the ISO C++ standardization committee in Wrocław, Poland. This was the fifth meeting for the upcoming C++26 standard and the feature freeze for major C++26 features.

Trip Report: Fall ISO C++ Meeting in Wrocław, Poland

by Jonathan Müller

From the article:

For an overview of all the papers that made progress, read Herb Sutter's trip reportContracts and profiles are the big ticket items that made the most progress this meeting. Contracts is forwarded to wording review, while still being fiercely opposed by some. Profiles is essentially standardized static analysis to improve memory safety, although some deem it ineffective. Due to various scheduling conflicts I did not attend any of the relevant discussions in these spaces. Instead, I am going to share my thoughts about ranges, relocation, and reflection.

Ranges

I've spent the first day and a half co-chairing SG 9, the study group for std::ranges. During discussions, we realized two big holes in the range library that we need to address as soon as possible. They both concern the concept of sized ranges.

The first hole is related to proposal P3179—C++ parallel range algorithms, which adds an execution policy to the algorithms in std::ranges. This makes it trivial to run multi-threaded algorithms: Instead of writing std::ranges::transform(vec, output, fn), you write std::ranges::transform(std::execution::par, vec, output, fn) and now your input is split into multiple chunks and processed in parallel.

PVS-Studio 7.34: support for Apple Silicon ARM64, CodeChecker

PVS-Studio 7.34 has been released. Discover the latest features, including support for Apple Silicon processors with ARM64 architecture, .NET 9 project compatibility, the introduction of the taint analysis mechanism in the Java analyzer, and more.

PVS-Studio 7.34: support for Apple Silicon ARM64, CodeChecker

by Aleksandra Uvarova

From the article:

New diagnostic rules. C, C++:

  • V1116. Creating an exception object without an explanatory message may result in insufficient logging.
  • V1117. The declared function type is cv-qualified. The behavior when using this type is undefined.
  • V2022. Implicit type conversion from integer type to enum type.
  • V5014. OWASP. Cryptographic function is deprecated. Its use can lead to security issues. Consider switching to an equivalent newer function.

 

2024-12 Mailing Available

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

 

WG21 Number Title Author Document Date Mailing Date Previous Version Subgroup
N4977 2025-11 Kona meeting information Herb Sutter 2024-12-16 2024-12   All of WG21
N4995 WG21 agenda: 18-23 November 2024, Wroclaw, Poland John Spicer 2024-10-28 2024-12   All of WG21
N4997 Hagenberg Meeting Invitation and Information Michael Hava 2024-11-19 2024-12   All of WG21
N4998 WG21 2024-11 Wroclaw Admin telecon minutes Nina Ranns 2024-11-20 2024-12   All of WG21
N4999 WG21 agenda: 10-15 February 2025, Hagenberg, Austria John Spicer 2024-12-02 2024-12   All of WG21
N5000 WG21 November 2024 Hybrid meeting Minutes of Meeting Nina Ranns 2024-12-11 2024-12   All of WG21
N5001 Working Draft, Programming Languages -- C++ Thomas Köppe 2024-12-17 2024-12   All of WG21
N5002 Editors' Report, Programming Languages -- C++ Thomas Köppe 2024-12-17 2024-12   All of WG21
N5003 2025 WG21 admin telecon meetings Herb Sutter 2024-12-16 2024-12   All of WG21
P0178R1 Allocators and swap Alisdair Meredith 2024-12-17 2024-12 P0178R0 LWG Library
P0260R12 C++ Concurrent Queues Detlef Vollmann 2024-11-21 2024-12 P0260R11 SG1 Concurrency and Parallelism,LEWG Library Evolution
P0260R13 C++ Concurrent Queues Detlef Vollmann 2024-12-10 2024-12 P0260R12 SG1 Concurrency and Parallelism,LEWG Library Evolution
P0447R27 Introduction of std::hive to the standard library Matt Bentley 2024-12-03 2024-12 P0447R26 SG14 Low Latency,LEWG Library Evolution,LWG Library,All of WG21
P0447R28 Introduction of std::hive to the standard library Matt Bentley 2024-12-16 2024-12 P0447R27 SG14 Low Latency,LEWG Library Evolution,LWG Library,All of WG21
P0472R3 Put std::monostate in <utility> David Sankel 2024-11-18 2024-12 P0472R2 LEWG Library Evolution
P1040R7 std::embed and #depend JeanHeyd Meneide 2024-12-15 2024-12 P1040R6 EWG Evolution
P1061R10 Structured Bindings can introduce a Pack Barry Revzin 2024-11-24 2024-12 P1061R9 CWG Core
P1928R13 std::simd - Merge data-parallel types from the Parallelism TS 2 Matthias Kretz 2024-11-22 2024-12 P1928R12 LWG Library
P1928R14 std::simd - Merge data-parallel types from the Parallelism TS 2 Matthias Kretz 2024-11-22 2024-12 P1928R13 LWG Library
P1928R15 std::simd - Merge data-parallel types from the Parallelism TS 2 Matthias Kretz 2024-11-22 2024-12 P1928R14 LWG Library
P1967R13 #embed - a simple, scannable preprocessor-based resource acquisition method JeanHeyd Meneide 2024-12-15 2024-12 P1967R12 EWG Evolution,CWG Core
P2014R1 Proposed resolution for US061/US062 - aligned allocation of coroutine frames Lewis Baker 2024-10-29 2024-12 P2014R0 CWG Core
P2014R2 Proposed resolution for US061/US062 - aligned allocation of coroutine frames Lewis Baker 2024-10-29 2024-12 P2014R1 CWG Core
P2319R3 Prevent path presentation problems Victor Zverovich 2024-11-18 2024-12 P2319R2 LEWG Library Evolution
P2319R4 Prevent path presentation problems Victor Zverovich 2024-12-07 2024-12 P2319R3 LEWG Library Evolution
P2645R1 path_view: a design that took a wrong turn Victor Zverovich 2024-11-17 2024-12 P2645R0 LEWG Library Evolution
P2645R1 path_view: a design that took a wrong turn Victor Zverovich 2024-11-17 2024-12 P2645R0 LEWG Library Evolution
P2656R4 WITHDRAWN: C++ Ecosystem International Standard René Ferdinand Rivera Morell 2024-12-16 2024-12 P2656R3 All of WG21
P2686R5 constexpr structured bindings and references to constexpr variables Corentin Jabot 2024-11-12 2024-12 P2686R4 CWG Core
P2688R4 Pattern Matching: `match` Expression Michael Park 2024-12-17 2024-12 P2688R3 EWG Evolution
P2717R6 WITHDRAWN: Tool Introspection René Ferdinand Rivera Morell 2024-12-16 2024-12 P2717R5 All of WG21
P2781R5 std::constexpr_wrapper Zach Laine 2024-11-14 2024-12 P2781R4 LEWG Library Evolution
P2786R10 Trivial Relocatability For C++26 Pablo Halpern 2024-11-21 2024-12 P2786R9 LEWG Library Evolution
P2786R11 Trivial Relocatability For C++26 Pablo Halpern 2024-12-17 2024-12 P2786R10 EWG Evolution,LEWG Library Evolution
P2786R9 Trivial Relocatability For C++26 Pablo Halpern 2024-11-15 2024-12 P2786R8 EWG Evolution,LEWG Library Evolution
P2825R3 Overload resolution hook: declcall( unevaluated-call-expression ) Gašper Ažman 2024-12-16 2024-12 P2825R2 EWG Evolution,CWG Core
P2830R5 Standardized Constexpr Type Ordering Gašper Ažman 2024-11-20 2024-12 P2830R4 EWG Evolution,LEWG Library Evolution,CWG Core
P2830R6 Standardized Constexpr Type Ordering Gašper Ažman 2024-11-20 2024-12 P2830R5 EWG Evolution,LEWG Library Evolution,CWG Core
P2830R7 Standardized Constexpr Type Ordering Gašper Ažman 2024-11-21 2024-12 P2830R6 EWG Evolution,LEWG Library Evolution,CWG Core
P2835R7 Expose std::atomic_ref's object address Gonzalo Brito Gadeschi 2024-11-18 2024-12 P2835R6 LWG Library
P2846R5 reserve_hint: Eagerly reserving memory for not-quite-sized lazy ranges Corentin Jabot 2024-11-27 2024-12 P2846R4 LEWG Library Evolution
P2863R8 Review Annex D for C++26 Alisdair Meredith 2024-12-13 2024-12 P2863R7 EWG Evolution,LEWG Library Evolution
P2865R6 Remove Deprecated Array Comparisons from C++26 Alisdair Meredith 2024-11-22 2024-12 P2865R5 CWG Core
P2866R5 Remove Deprecated Volatile Features From C++26 Alisdair Meredith 2024-12-17 2024-12 P2866R4 EWG Evolution,CWG Core,LWG Library
P2897R6 aligned_accessor: An mdspan accessor expressing pointer overalignment Mark Hoemmen 2024-11-18 2024-12 P2897R5 LEWG Library Evolution,LWG Library
P2897R7 aligned_accessor: An mdspan accessor expressing pointer overalignment Mark Hoemmen 2024-11-22 2024-12 P2897R6 LWG Library
P2900R11 Contracts for C++ Joshua Berne 2024-11-19 2024-12 P2900R10 EWG Evolution,LEWG Library Evolution
P2900R12 Contracts for C++ Joshua Berne 2024-12-17 2024-12 P2900R11 CWG Core,LWG Library
P2996R8 Reflection for C++26 Barry Revzin 2024-12-16 2024-12 P2996R7 EWG Evolution
P3008R3 Atomic floating-point min/max Gonzalo Brito Gadeschi 2024-11-18 2024-12 P3008R2 LWG Library
P3016R5 Resolve inconsistencies in begin/end for valarray and braced initializer lists Arthur O'Dwyer 2024-12-16 2024-12 P3016R4 LEWG Library Evolution
P3019R11 Vocabulary Types for Composite Class Design Jonathan Coe 2024-11-23 2024-12 P3019R10 LEWG Library Evolution,LWG Library
P3037R4 constexpr std::shared_ptr Paul Keir 2024-10-21 2024-12 P3037R3 LEWG Library Evolution
P3045R4 Quantities and units library Mateusz Pusz 2024-11-15 2024-12 P3045R3 SG6 Numerics,SG16 Unicode,LEWG Library Evolution
P3050R3 Fix C++26 by optimizing linalg::conjugated for noncomplex value types Mark Hoemmen 2024-10-29 2024-12 P3050R2 LEWG Library Evolution
P3051R3 WITHDRAWN: Structured Response Files René Ferdinand Rivera Morell 2024-12-16 2024-12 P3051R2 All of WG21
P3068R5 Allowing exception throwing in constant-evaluation Hana Dusíková 2024-11-19 2024-12 P3068R4 CWG Core,LWG Library
P3068R6 Allowing exception throwing in constant-evaluation Hana Dusíková 2024-11-19 2024-12 P3068R5 CWG Core,LWG Library
P3074R5 trivial unions (was std::uninitialized<T>) Barry Revzin 2024-12-17 2024-12 P3074R4 EWG Evolution
P3096R4 Function Parameter Reflection in Reflection for C++26 Adam Lach 2024-11-21 2024-12 P3096R3 LEWG Library Evolution
P3096R5 Function Parameter Reflection in Reflection for C++26 Adam Lach 2024-12-14 2024-12 P3096R4 LEWG Library Evolution,LWG Library
P3098R1 Contracts for C++: Postcondition captures Timur Doumler 2024-12-11 2024-12 P3098R0 SG21 Contracts,EWG Evolution
P3111R1 Atomic Reduction Operations Gonzalo Brito Gadeschi 2024-11-18 2024-12 P3111R0 SG1 Concurrency and Parallelism
P3111R2 Atomic Reduction Operations Gonzalo Brito Gadeschi 2024-11-25 2024-12 P3111R1 EWG Evolution,LEWG Library Evolution
P3117R1 Extending Conditionally Borrowed Zach Laine 2024-12-14 2024-12 P3117R0 SG9 Ranges,LEWG Library Evolution
P3125R2 constexpr pointer tagging Hana Dusíková 2024-11-27 2024-12 P3125R1 LEWG Library Evolution
P3136R1 Retiring niebloids Tim Song 2024-11-18 2024-12 P3136R0 LWG Library
P3138R4 views::cache_latest Tim Song 2024-10-23 2024-12 P3138R3 LEWG Library Evolution,LWG Library
P3138R5 views::cache_latest Tim Song 2024-11-18 2024-12 P3138R4 LWG Library
P3146R2 Clarifying std::variant converting construction Giuseppe D'Angelo 2024-11-02 2024-12 P3146R1 LEWG Library Evolution,LWG Library
P3149R7 async_scope -- Creating scopes for non-sequential concurrency Ian Petersen 2024-11-18 2024-12 P3149R6 SG1 Concurrency and Parallelism,LEWG Library Evolution
P3149R8 async_scope -- Creating scopes for non-sequential concurrency Ian Petersen 2024-11-22 2024-12 P3149R7 SG1 Concurrency and Parallelism,LEWG Library Evolution
P3152R1 Add missing constructors and assignment for indirect and polymorphic Jonathan Coe 2024-11-21 2024-12 P3152R0 LEWG Library Evolution
P3179R4 C++ parallel range algorithms Ruslan Arutyunyan 2024-12-10 2024-12 P3179R3 LEWG Library Evolution
P3185R0 A proposed direction for C++ Standard Networking based on IETF TAPS Thomas Rodgers 2024-12-14 2024-12   SG4 Networking
P3204R0 Why Contracts? Joshua Berne 2024-11-07 2024-12   SG21 Contracts,EWG Evolution
P3222R1 Fix C++26 by adding transposed special cases for P2642 layouts Mark Hoemmen 2024-10-29 2024-12 P3222R0 LEWG Library Evolution
P3227R1 Fixing the library API for contract violation handling Gašper Ažman 2024-10-24 2024-12 P3227R0 SG21 Contracts,LEWG Library Evolution
P3230R1 views::unchecked_(take|drop) Hewill Kang 2024-12-01 2024-12 P3230R0 SG9 Ranges,LEWG Library Evolution,LWG Library
P3232R1 User-defined erroneous behaviour Thomas Köppe 2024-12-15 2024-12 P3232R0 SG12 Undefined and Unspecified Behavior,SG23 Safety and Security,EWG Evolution,LEWG Library Evolution
P3237R2 Matrix Representation of Contract Semantics Andrei Zissu 2024-10-23 2024-12 P3237R1 SG21 Contracts
P3247R2 Deprecate the notion of trivial types Jens Maurer 2024-10-28 2024-12 P3247R1 CWG Core,LWG Library
P3261R2 Revisiting `const`-ification in Contract Assertions Joshua Berne 2024-11-25 2024-12 P3261R1 SG21 Contracts,EWG Evolution
P3284R2 `write_env` and `unstoppable` Sender Adaptors Eric Niebler 2024-11-21 2024-12 P3284R1 LEWG Library Evolution
P3287R2 Exploration of namespaces for std::simd Matthias Kretz 2024-11-13 2024-12 P3287R1 LEWG Library Evolution
P3296R3 let_async_scope Anthony Williams 2024-11-19 2024-12 P3296R2 SG1 Concurrency and Parallelism,LEWG Library Evolution
P3299R3 Range constructors for std::simd Daniel Towner 2024-12-17 2024-12 P3299R2 LEWG Library Evolution,LWG Library
P3309R3 constexpr atomic and atomic_ref Hana Dusíková 2024-12-16 2024-12 P3309R2 LWG Library
P3310R5 Solving issues introduced by relaxed template template parameter matching Matheus Izvekov 2024-11-21 2024-12 P3310R4 EWG Evolution,CWG Core
P3319R2 Add an iota object for simd (and more) Matthias Kretz 2024-11-19 2024-12 P3319R1 LEWG Library Evolution
P3323R1 cv-qualified types in atomic and atomic_ref Gonzalo Brito Gadeschi 2024-11-18 2024-12 P3323R0 LWG Library
P3325R4 A Utility for Creating Execution Environments Eric Niebler 2024-11-21 2024-12 P3325R3 LWG Library
P3325R5 A Utility for Creating Execution Environments Eric Niebler 2024-11-22 2024-12 P3325R4 LWG Library
P3329R0 Healing the C++ Filter View Nicolai Josuttis 2024-11-13 2024-12   SG9 Ranges,LEWG Library Evolution,LWG Library
P3335R3 Structured Core Options René Ferdinand Rivera Morell 2024-11-21 2024-12 P3335R2 SG15 Tooling
P3335R4 WITHDRAWN: Structured Core Options René Ferdinand Rivera Morell 2024-12-16 2024-12 P3335R3 All of WG21
P3339R1 WITHDRAWN: C++ Ecosystem IS Open License René Ferdinand Rivera Morell 2024-12-16 2024-12 P3339R0 All of WG21
P3342R1 Working Draft, Standard for C++ Ecosystem René Ferdinand Rivera Morell 2024-11-21 2024-12 P3342R0 EWG Evolution,CWG Core
P3342R2 WITHDRAWN: Working Draft, Standard for C++ Ecosystem René Ferdinand Rivera Morell 2024-12-16 2024-12 P3342R1 All of WG21
P3355R2 Fix submdspan for C++26 Mark Hoemmen 2024-10-29 2024-12 P3355R1 LWG Library
P3367R1 constexpr coroutines Hana Dusíková 2024-11-29 2024-12 P3367R0 CWG Core
P3367R2 constexpr coroutines Hana Dusíková 2024-12-16 2024-12 P3367R1 EWG Evolution,LWG Library
P3371R3 Fix C++26 by making the rank-1, rank-2, rank-k, and rank-2k updates consistent with the BLAS Mark Hoemmen 2024-10-29 2024-12 P3371R2 LEWG Library Evolution
P3378R1 constexpr exception types Hana Dusíková 2024-12-16 2024-12 P3378R0 LEWG Library Evolution
P3380R1 Extending support for class types as non-type template parameters Barry Revzin 2024-12-17 2024-12 P3380R0 EWG Evolution
P3383R1 mdspan.at() Stephan Lachnit 2024-11-23 2024-12 P3383R0 LEWG Library Evolution
P3385R2 Attributes reflection Aurelien Cassagnes 2024-12-11 2024-12 P3385R1 SG7 Reflection
P3386R1 Static Analysis of Contracts with P2900 Joshua Berne 2024-11-25 2024-12 P3386R0 EWG Evolution
P3396R1 std::execution wording fixes Lewis Baker 2024-11-19 2024-12 P3396R0 LWG Library
P3409R1 Enabling more efficient stop-token based cancellation of senders Lewis Baker 2024-11-17 2024-12 P3409R0 SG1 Concurrency and Parallelism
P3422R1 Allow main function in named modules Chuanqi Xu 2024-11-27 2024-12 P3422R0 EWG Evolution
P3424R0 Define Delete With Throwing Exception Specification Alisdair Meredith 2024-12-17 2024-12   LEWGI SG18: LEWG Incubator,EWG Evolution
P3427R1 Hazard Pointer Synchronous Reclamation Maged Michael 2024-12-11 2024-12 P3427R0 SG1 Concurrency and Parallelism
P3428R1 Hazard Pointer Batches Maged Michael 2024-12-11 2024-12 P3428R0 SG1 Concurrency and Parallelism
P3429R1 Reflection header should minimize standard library dependencies Jonathan Müller 2024-11-29 2024-12 P3429R0 LEWG Library Evolution
P3430R1 simd issues: explicit, unsequenced, identity-element position, and members of disabled simd Matthias Kretz 2024-11-22 2024-12 P3430R0 LEWG Library Evolution
P3436R1 Strategy for removing safety-related undefined behavior by default Herb Sutter 2024-11-07 2024-12 P3436R0 SG23 Safety and Security,EWG Evolution
P3437R1 Proposed principles: Reflect C++, generate C++ (by default) Herb Sutter 2024-11-07 2024-12 P3437R0 SG7 Reflection,EWG Evolution
P3449R1 constexpr std::generator Hana Dusíková 2024-12-16 2024-12 P3449R0 LWG Library
P3466R1 (Re)affirm design principles for future C++ evolution Herb Sutter 2024-11-24 2024-12 P3466R0 EWG Evolution
P3468R0 2024-10 Library Evolution Poll Outcomes Inbal Levi 2024-12-16 2024-12   LEWG Library Evolution
P3471R1 Standard Library Hardening Konstantin Varlamov 2024-11-21 2024-12 P3471R0 SG23 Safety and Security,LEWG Library Evolution
P3471R2 Standard Library Hardening Konstantin Varlamov 2024-12-14 2024-12 P3471R1 SG23 Safety and Security,LEWG Library Evolution
P3477R1 There are exactly 8 bits in a byte JF Bastien 2024-11-21 2024-12 P3477R0 SG22 Compatibility,LEWG Library Evolution,CWG Core
P3480R1 std::simd is a range Matthias Kretz 2024-11-13 2024-12 P3480R0 SG9 Ranges,LEWG Library Evolution
P3480R2 std::simd is a range Matthias Kretz 2024-11-22 2024-12 P3480R1 LEWG Library Evolution
P3482R0 Proposed API for creating TAPS based networking connections Thomas W Rodgers 2024-12-14 2024-12   SG4 Networking
P3483R0 Contracts for C++: Pre-Wroclaw technical clarifications Timur Doumler 2024-10-31 2024-12   SG21 Contracts,EWG Evolution
P3483R1 Contracts for C++: Pre-Wroclaw technical clarifications Timur Doumler 2024-11-04 2024-12 P3483R0 SG21 Contracts,EWG Evolution
P3484R0 Postconditions odr-using a parameter modified in an overriding function Timur Doumler 2024-11-01 2024-12   SG21 Contracts,EWG Evolution
P3484R1 Postconditions odr-using a parameter modified in an overriding function Timur Doumler 2024-11-07 2024-12 P3484R0 SG21 Contracts,EWG Evolution
P3484R2 Postconditions odr-using a parameter modified in an overriding function Timur Doumler 2024-11-14 2024-12 P3484R1 SG21 Contracts,EWG Evolution
P3485R0 Grouping using declarations with braces Barry Revzin 2024-10-29 2024-12   EWG Evolution
P3487R0 Postconditions odr-using a parameter that may be passed in registers Timur Doumler 2024-11-07 2024-12   SG21 Contracts,EWG Evolution
P3488R0 Floating-Point Excess Precision Matthias Kretz 2024-11-14 2024-12   SG6 Numerics,EWG Evolution
P3488R1 Floating-Point Excess Precision Matthias Kretz 2024-11-20 2024-12 P3488R0 EWG Evolution
P3489R0 Postconditions odr-using a parameter of dependent type Timur Doumler 2024-11-07 2024-12   SG21 Contracts,EWG Evolution
P3490R0 Justification for ranges as the output of parallel range algorithms Alexey Kukanov 2024-11-14 2024-12   SG1 Concurrency and Parallelism,SG9 Ranges
P3491R0 define_static_{string,object,array} Barry Revzin 2024-12-15 2024-12   LEWG Library Evolution
P3492R0 Sized deallocation for placement new Lauri Vasama 2024-11-22 2024-12   EWGI SG17: EWG Incubator
P3493R0 Ruminations on reflection and access Ville Voutilainen 2024-11-10 2024-12   SG7 Reflection,LEWG Library Evolution
P3495R0 Remarks on Basic Statistics, P1708R9 Oliver Rosten 2024-11-13 2024-12   SG19 Machine Learning,LEWG Library Evolution,LWG Library
P3497R0 Guarded Objects Jan Wilmans 2024-11-11 2024-12   SG1 Concurrency and Parallelism
P3498R0 Stop the Bleeding but, First, Do No Harm Gabriel Dos Reis 2024-11-14 2024-12   SG23 Safety and Security,EWG Evolution
P3502R0 Slides for D2900R11 - Contracts for C++ Timur Doumler 2024-11-18 2024-12   EWG Evolution
P3503R0 Make type-erased allocator use in promise and packaged_task consistent Nicolas Morales 2024-11-21 2024-12   LEWG Library Evolution
P3504R0 C++ Standard Library Ready Issues to be moved in Wroclaw, Nov. 2024 Jonathan Wakely 2024-11-18 2024-12   All of WG21
P3508R0 Wording for constexpr for specialized memory algorithms Giuseppe D'Angelo 2024-11-20 2024-12   LWG Library
P3510R0 Leftover properties of `this` in constructor preconditions Nathan Myers 2024-11-20 2024-12   SG21 Contracts
P3510R1 Leftover properties of `this` in constructor preconditions Nathan Myers 2024-11-21 2024-12 P3510R0 SG21 Contracts
P3510R2 Leftover properties of `this` in constructor preconditions Nathan Myers 2024-12-04 2024-12 P3510R1 SG21 Contracts
P3517R0 Slides presented to LEWG on trivial relocation in Wroclaw Alisdair Meredith 2024-11-20 2024-12   LEWG Library Evolution
P3518R0 Slides for Standardized Constexpr Type Ordering Gašper Ažman 2024-11-20 2024-12   EWG Evolution
P3519R0 Slides for P3425 presentation to LEWG Lewis Baker 2024-11-20 2024-12   LEWG Library Evolution
P3520R0 Wroclaw Technical Fixes to Contracts Timur Doumler 2024-11-21 2024-12   SG21 Contracts,EWG Evolution
P3521R0 Pattern Matching: Customization Point for Open Sum Types Michael Park 2024-12-17 2024-12   EWG Evolution,LEWG Library Evolution
P3524R0 Core Language Working Group "ready" Issues for the November, 2024 meeting Jens Maurer 2024-11-23 2024-12   CWG Core
P3525R0 Explicit Implicit Template Regions Barry Revzin 2024-12-16 2024-12   EWG Evolution
P3527R0 Pattern Matching: *variant-like* and `std::expected` Michael Park 2024-12-17 2024-12   EWG Evolution,LEWG Library Evolution
P3530R0 Intrinsic for reading uninitialized memory Boleyn Su 2024-12-17 2024-12   EWGI SG17: EWG Incubator,EWG Evolution,LEWG Library Evolution,CWG Core,LWG Library

C++ programmer's guide to undefined behavior: part 11 of 11

Your attention is invited to the 11th part of an e-book on undefined behavior. This is not a textbook, as it's intended for those who are already familiar with C++ programming. It's a kind of C++ programmer's guide to undefined behavior and to its most secret and exotic corners. The book was written by Dmitry Sviridkin and edited by Andrey Karpov.

C++ programmer's guide to undefined behavior: part 11 of 11

by Dmitry Sviridkin

From the article:

Developing multithreaded applications is always challenging. The problem of synchronizing access to shared data is a perennial headache. It'd be ideal if we had a well-tested, reliable library of containers, high-level primitives, and parallel algorithms that managed all invariants. It'd be ideal if static compiler checks prevented us from misusing all these things. How nice it would be... Before C++11 and the standardized memory model, we could use threads but only at our risk. Starting with C++11, there are some pretty low-level primitives in the standard library. Since C++17, there are still various parallel versions of algorithms, but we can't even fine-tune the number of threads or their priorities.

The Puzzle of Trying to Put an Object into a std::optional -- Raymond Chen

RaymondChen_5in-150x150.jpgThe std::optional<T> is a powerful tool for handling optional values, but assigning non-trivial types like Doodad to it can lead to unexpected compilation errors. This post explores why such assignments fail and unpacks the nuances of std::optional and type construction in modern C++.

The Puzzle of Trying to Put an Object into a std::optional

by Raymond Chen

From the article:

The C++ standard library template type std::optional<T> has one of two states. It could be empty (not contain anything), or it could contain a T.

Suppose you start with an empty std::optional<T>. How do you put a T into it?

One of my colleagues tried to do it in what seemed to be the most natural way: Use the assignment operator.

struct Doodad
{
    Doodad();
    ~Doodad();
    std::unique_ptr<DoodadStuff> m_stuff;
};

struct Widget
{
    std::optional<Doodad> m_doodad;

    Widget()
    {
        if (doodads_enabled()) {
            // I guess we need a Doodad too.
            Doodad d;
            m_doodad = d;
        }
    }
};

Unfortunately, the assignment failed to compile:

Implicit String Conversions to Booleans -- Sandor Dargo

SANDOR_DARGO_ROUND.JPGIn this article, we'll learn about -Wstring-conversion, something I learned from C++ Brain Teasers by Anders Schau Knatten](https://www.sandordargo.com/blog/2024/10/16/cpp-brain-teasers). Clang offers this compiler warning which fires on implicit conversions from C-strings to bools.

Implicit String Conversions to Booleans

by Sandor Dargo

From the article:

Let’s start with the first part by explaining why such an implicit conversion is possible. A string literal is an array of const chars. Arrays can be converted into pointers, something we talked about last week when we discussed why spans are so useful. This is also called decay. Furthermore, pointers can be converted into booleans. That is how a string literal can be converted into a bool.

static_assert(!!"" == true);
static_assert(static_cast<bool>("") == true);

What might be surprising though is that even an empty string literal is converted into true. The reason is that only a nullptr would be converted into false, but an empty string literal is an array of a size of one so it’s not a nullptr. As a result, "" converted to true. The possible confusion is that the one character in that array of one is the \0 terminator. But this shouldn’t really matter. You shouldn’t use such shady implicit conversions.

We could end this article right here. But life is not ideal and I tried to turn on -Wstring-conversion in a production codebase where I found a few different cases of string literals conversions.