How do I design a class so that methods must be called in a certain order?—Raymond Chen

Simple but effective.

How do I design a class so that methods must be called in a certain order?

by Raymond Chen

From the article:

Suppose you have a class with some methods, and the methods must be called in a certain order. For example, suppose your class is for importing photos from a camera. First, you have to specify which camera you are importing from. Then you discover the pictures. Then you have to select which pictures you want to import, and set the options for how you want the download to occur. And finally, you download them...

C++ Insights - Implicit Conversions—Andreas Fertig

A good tool!

C++ Insights - Implicit Conversions

by Andreas Fertig

From the article:

This series is motivated by a brief conversation I had with Andreas. I asked him if he has some use case examples which show how C++ Insights can be helpful when teaching. I think there are many things. This article is the start of a series of five posts by Andreas which I will publish at Modernes C++ because I think C++ Insights is an invaluable tool to get a deeper insight in the C++ compiler magic. In case, you are new to C++ Insights consider this introductory article. Without further ado, Andreas post. When you follow the link near to each example, you can directly analyse the example in C++ Insight...

Quick Q: Deletion of copy-ctor & copy-assignment - public, private or protected?

Quick A: The meaning is the same for the compiler, so chooses what make sense to you.

Recently on SO:

Deletion of copy-ctor & copy-assignment - public, private or protected?

I would put them in the public section.

This is because deleting a constructor or an assignment operator is orthogonal to making them private / protected; and when these aren't deleted, they are public. Putting the deletions in one of those two sections seems to me like hinting "If I hadn't deleted them, I would have made them private/protected" - which is not a message you want to convey in your case.

Note, though, that the compiler doesn't care which section you put the deletion in.

2019-03 post-Kona mailing available

The 2019-03 mailing of new standards papers is now available.


2019-03 post-Kona
N4801 WG21 pre-Kona telecon minutes Nina Dinka Ranns 2019-02-08 2019-03 WG21
N4802 WG21 2018-11 San Diego Minutes Nina Dinka Ranns 2018-11-26 2019-03 N4790 WG21
N4803 Kona 2019 LEWG Summary Titus Winters 2019-02-24 2019-03 WG21
N4805 WG21 2019-02 Kona Minutes of Meeting Nina Dinka Ranns 2019-03-10 2019-03 WG21
N4806 Working Draft, C++ Extensions for Library Fundamentals, Version 3 Thomas Köppe 2019-03-13 2019-03 N4786 WG21
N4807 Editor’s Report: C++ Extensions for Library Fundamentals, Version 3 Thomas Köppe 2019-03-13 2019-03 WG21
N4808 Working Draft, C++ Extensions for Parallelism Version 2 Jared Hoberock 2019-03-11 2019-03 N4796 WG21
N4809 Parallelism TS Editor’s Report, post-Kona mailing Jared Hoberock 2019-03-11 2019-03 WG21
N4810 Working Draft, Standard for Programming Language C++ Richard Smith 2019-03-15 2019-03 N4800 WG21
N4811 Editors' Report - Programming Languages - C++ Richard Smith 2019-03-15 2019-03 WG21
P0052R10 Generic Scope Guard and RAII Wrapper for the Standard Library Peter Sommerlad, Andrew L. Sandoval 2019-02-19 2019-03 P0052R9 Library Adopted 2019-03
P0201R5 A polymorphic value-type for C++ Jonathan Coe, Sean Parent 2019-03-11 2019-03 P0201R4 Library Evolution, Library
P0339R6 polymorphic_allocator<> as a vocabulary type Pablo Halpern, Dietmar Kühl 2019-02-22 2019-03 P0339R5 Library Adopted 2019-03
P0340R3 Making std::underlying_type SFINAE-friendly Tim Song 2019-02-21 2019-03 P0340R2 Library Adopted 2019-03
P0466R3 Layout-compatibility and Pointer-interconvertibility Traits Lisa Lippincott 2019-03-08 2019-03 P0466R2 Library
P0553R4 Bit operations Jens Maurer 2019-03-01 2019-03 P0553R3 Library
P0631R6 Math Constants Lev Minkovsky, John McFarlane 2019-02-25 2019-03 P0631R5 Library
P0645R7 Text Formatting Victor Zverovich 2019-03-09 2019-03 P0645R6 Library Evolution, Library
P0660R9 Stop Token and Joining Thread Nicolai Josuttis, Lewis Baker, Billy O’Neal, Herb Sutter, Anthony Williams 2019-03-10 2019-03 P0660R8 SG1, Library Evolution, Library
P0664R8 C++ Coroutine TS Issues Gor Nishanov 2019-02-21 2019-03 P0664R7 Core
P0738R2 I Stream, You Stream, We All Stream for istream_iterator Casey Carter 2019-02-21 2019-03 P0738R1 Library Adopted 2019-03
P0798R4 Monadic operations for std::optional Simon Brand 2019-03-11 2019-03 P0798R3 Library
P0811R3 Well-behaved interpolation for numbers and pointers S. Davis Herring 2019-02-22 2019-03 P0811R2 Library Adopted 2019-03
P0813R1 construct() shall Return the Replaced Address Nicolai Josuttis 2019-02-20 2019-03 P0813R0 Library Evolution, Library
P0881R4 A Proposal to add stacktrace library Alexey Gorgurov, Antony Polukhin 2019-01-22 2019-03 P0881R3 Core, Library
P0912R5 Merge Coroutines TS into C++20 working draft Gor Nishanov 2019-02-22 2019-03 P0912R4 WG21 Adopted 2019-03
P0920R2 Precalculated hash values in lookup Mateusz Pusz 2019-02-22 2019-03 P0920R1 Library Adopted 2019-03
P0943R2 Support C atomics in C++ Hans-J. Boehm 2019-03-10 2019-03 P0943R1 SG1, Library Evolution
P0960R3 Allow initializing aggregates from a parenthesized list of values Ville Voutilainen, Thomas Köppe 2019-02-22 2019-03 P0960R2 Evolution, Core Adopted 2019-03
P0985R4 LWG Chair post-meeting report Marshall Clow 2019-03-10 2019-03 P0985R3 WG21
P1001R2 Target Vectorization Policies from Parallelism V2 TS to C++20 Alisdair Meredith, Pablo Halpern 2019-02-22 2019-03 P1001R1 SG1, Library Adopted 2019-03
P1009R2 Array size deduction in new-expressions Timur Doumler 2019-02-22 2019-03 P1009R1 Core Adopted 2019-03
P1018R3 Evolution status after Kona 2019 Ville Voutilainen 2019-03-11 2019-03 P1018R2 WG21
P1024R3 Usability Enhancements for std::span Tristan Brindle 2019-02-22 2019-03 P1024R2 Library Adopted 2019-03
P1035R5 Input Range Adaptors Christopher Di Bella, Casey Carter, Corentin Jabot 2019-03-05 2019-03 P1035R4 Library
P1041R4 Make char16_t/char32_t string literals be UTF-16/32 R. Martinho Fernandes 2019-02-18 2019-03 P1041R3 Evolution, Core Adopted 2019-03
P1091R3 Extending structured bindings to be more like variable declarations Nicolas Lesser 2019-02-18 2019-03 P1091R2 Core Adopted 2019-03
P1099R4 Using Enum Gašper Ažman, Jonathan Müller 2019-03-10 2019-03 P1099R3 Core
P1103R3 Merging Modules Richard Smith 2019-02-22 2019-03 P1103R2 WG21 Adopted 2019-03
P1135R4 The C++20 Synchronization Library Bryce Adelstein Lelbach, Olivier Giroux, JF Bastien, Detlef Vollmann, David Olsen 2019-03-04 2019-03 P1135R3 Library
P1139R2 Address wording issues related to ISO 10646 R. Martinho Fernandes 2019-02-18 2019-03 P1139R1 SG16, Core Adopted 2019-03
P1144R3 Object relocation in terms of move plus destroy Arthur O'Dwyer 2019-03-10 2019-03 P1144R2 Library Evolution, Library
P1152R2 Deprecating volatile JF Bastien 2019-03-09 2019-03 P1152R1 Core, Library Evolution, Library
P1154R2 Type traits for structural comparison Arthur O'Dwyer, Jeff Snyder 2019-03-10 2019-03 P1154R1 Library
P1161R3 Deprecate uses of the comma operator in subscripting expressions Corentin Jabot 2019-02-22 2019-03 P1161R2 Core
P1164R1 Make create_directory() intuitive Nicolai Josuttis 2019-02-22 2019-03 P1164R0 Library Adopted 2019-03
P1185R2 <=> != == Barry Revzin 2019-02-22 2019-03 P1185R1 Evolution, Core Adopted 2019-03
P1189R0 Adding <=> to library Barry Revzin 2019-03-10 2019-03 Library Evolution
P1208R4 Adopt source location from Library Fundamentals V3 for C++20 Robert Douglas, Corentin Jabot 2019-03-11 2019-03 P1208R3 Library
P1217R1 Out-of-thin-air, revisited, again Hans-J. Boehm 2019-03-10 2019-03 P1217R0 SG1
P1219R1 Homogeneous variadic function parameters James Touton 2019-03-11 2019-03 P1219R0 Evolution
P1227R2 Signed ssize() functions, unsigned size() functions Jorg Brown 2019-02-22 2019-03 P1227R1 Library Adopted 2019-03
P1243R2 Rangify New Algorithms Dan Raviv 2019-03-09 2019-03 P1243R1 Library
P1252R2 Ranges Design Cleanup Casey Carter 2019-02-22 2019-03 P1252R1 Library Adopted 2019-03
P1255R3 A view of 0 or 1 elements: view::maybe Steve Downey 2019-03-10 2019-03 P1255R2 Library Evolution
P1257R0 Implementation experience on trying to implement concurrent data and control structures with executors Detlef Vollmann 2018-10-16 2019-03 SG1, Library Evolution
P1272R1 Byteswapping for fun&&nuf Isabella Muerte 2019-02-21 2019-03 P1272R0 Library
P1286R2 Contra CWG DR1778 Richard Smith 2019-02-18 2019-03 P1286R1 Core, Library Adopted 2019-03
P1290R2 Avoiding undefined behavior in contracts J. Daniel Garcia, Ville Voutilainen 2019-02-20 2019-03 P1290R1 Evolution, Core
P1290R3 Avoiding undefined behavior in contracts J. Daniel Garcia, Ville Voutilainen 2019-03-09 2019-03 P1290R2 Evolution, Core
P1323R2 Contract postconditions and return type deduction Hubert S.K. Tong 2019-02-20 2019-03 P1323R1 Core Adopted 2019-03
P1338R1 WG21 2018-11 San Diego Record of Discussion Nina Dinka Ranns 2018-11-26 2019-03 P1338R0 WG21
P1339R1 Disallowing the friending of names in namespace std CJ Johnson 2019-03-04 2019-03 P1339R0 Library Evolution, Library
P1344R1 Pre/Post vs. Enspects/Exsures Nathan Myers 2019-02-20 2019-03 P1344R0 Core
P1354R0 SG7 Guidelines for Review of Proposals Chandler Carruth 2018-11-08 2019-03 SG7
P1357R1 Traits for [Un]bounded Arrays Walter E. Brown, Glen J. Fernandes 2019-02-22 2019-03 P1357R0 Library Adopted 2019-03
P1358R0 Core "ready" Issues William M. Miller 2019-02-22 2019-03 WG21 Adopted 2019-03
P1359R0 Core "tentatively ready" Issues William M. Miller 2019-02-21 2019-03 WG21 Adopted 2019-03
P1368R1 Multiplication and division of fixed-point numbers S. Davis Herring 2019-03-05 2019-03 P1368R0 SG6
P1370R1 Generic numerical algorithm development with(out) numeric_limits Mark Hoemmen, Damien Lebrun-Grandie 2019-03-10 2019-03 P1370R0 SG6, Library Evolution Incubator
P1375R1 More Constrained: Apples or Oranges? On the road to semantic constraint matching Hubert S.K. Tong 2019-03-11 2019-03 P1375R0 Evolution
P1381R1 Reference capture of structured bindings Nicolas Lesser 2019-02-22 2019-03 P1381R0 Evolution Adopted 2019-03
P1382R1 volatile_load<T> and volatile_store<T> JF Bastien, Paul McKenney, Jeffrey Yasskin 2019-03-10 2019-03 P1382R0 SG1
P1385R1 A proposal to add linear algebra support to the C++ standard library Guy Davidson, Bob Steagall 2019-03-10 2019-03 P1385R0 SG14, Library Evolution
P1386R1 A Standard Audio API for C++: Motivation, Scope, and Basic Design Guy Somberg, Guy Davidson, Timur Doumler 2019-03-11 2019-03 P1386R0 SG13, Library Evolution
P1390R1 Reflection TS NB comment resolutions: summary and rationale Matúš Chochlík, Axel Naumann, and David Sankel 2019-02-22 2019-03 P1390R0 SG7, Evolution, Core, Library Evolution, Library Adopted 2019-03
P1391R1 Range constructor for std::string_view Corentin Jabot 2019-03-08 2019-03 P1391R0 Library
P1394R1 Range constructor for std::span Corentin Jabot, Casey Carter 2019-03-11 2019-03 P1394R0 Library
P1407R1 Tell Programmers About Signed Integer Overflow Behavior Scott Schurr 2019-03-08 2019-03 P1407R0 SG12
P1423R1 char8_t backward compatibility remediation Tom Honermann 2019-03-09 2019-03 P1423R0 Library
P1429R1 Contracts That Work Joshua Berne, John Lakos 2019-03-08 2019-03 P1429R0 Evolution
P1430R1 First-class symmetric coroutines in C++ Mihail Mihaylov, Vassil Vassilev 2019-02-08 2019-03 P1430R0 Evolution
P1438R1 A Rational Number Library for C++ Bill Seymour 2019-03-10 2019-03 P1438R0 SG6
P1439R1 Charset Transcoding, Transformation, and Transliteration Steve Downey 2019-03-10 2019-03 P1439R0 SG16
P1441R1 Are modules fast? Rene Rivera 2019-03-06 2019-03 P1441R0 WG21
P1452R1 On the non-uniform semantics of return-type-requirements Hubert S.K. Tong 2019-03-11 2019-03 P1452R0 Evolution
P1458R1 Mandating the Standard Library: Clause 16 - Language support library Marshall Clow 2019-02-20 2019-03 P1458R0 Library Adopted 2019-03
P1459R1 Mandating the Standard Library: Clause 18 - Diagnostics library Marshall Clow 2019-02-20 2019-03 P1459R0 Library Adopted 2019-03
P1462R1 Mandating the Standard Library: Clause 20 - Strings library Marshall Clow 2019-02-20 2019-03 P1462R0 Library Adopted 2019-03
P1463R1 Mandating the Standard Library: Clause 21 - Containers library Marshall Clow 2019-02-22 2019-03 P1463R0 Library Adopted 2019-03
P1464R1 Mandating the Standard Library: Clause 22 - Iterators library Marshall Clow 2019-02-20 2019-03 P1464R0 Library Adopted 2019-03
P1466R1 Miscellaneous minor fixes for chrono Howard E. Hinnant 2019-03-10 2019-03 P1466R0 Library
P1477R1 Coroutines TS Simplifications Lewis Baker 2019-02-12 2019-03 P1477R0 Evolution
P1478R0 Byte-wise atomic memcpy Hans-J. Boehm 2019-01-20 2019-03 SG1
P1478R1 Byte-wise atomic memcpy Hans-J. Boehm 2019-03-10 2019-03 P1478R0 SG1
P1482R0 Modules Feedback Bruno Cardoso Lopes, Michael Spencer, JF Bastien 2019-02-08 2019-03 SG15, Evolution
P1484R1 A uniform and predefined mapping from modules to filenames Peter Bindels 2019-03-11 2019-03 P1484R0 SG15
P1485R0 Better keywords for the Coroutines TS Antony Polukhin 2019-02-17 2019-03 Evolution
P1490R0 Contract-Related Issues Andrzej Krzemieński 2018-02-13 2019-03 Evolution
P1491R0 Don’t add to the signed/unsigned mess Bjarne Stroustrup 2019-02-14 2019-03 Evolution, Library Evolution
P1492R0 Coroutines: Language and Implementation Impact Richard Smith, Daveed Vandevoorde, Geoffrey Romer, Gor Nishanov, Nathan Sidwell, Iain Sandoe, Lewis Baker 2019-02-19 2019-03 WG21
P1493R0 Coroutines: Use-cases and Trade-offs Geoffrey Romer, Gor Nishanov, Lewis Baker, Mihail Mihailov 2019-02-19 2019-03 WG21
P1494R0 Partial program correctness S. Davis Herring 2019-03-07 2019-03 Evolution, Core, Library Evolution
P1498R0 Constrained Internal Linkage for Modules Chandler Carruth, Nathan Sidwell, Richard Smith 2019-02-20 2019-03 Evolution
P1498R1 Constrained Internal Linkage for Modules Chandler Carruth, Nathan Sidwell, Richard Smith 2019-02-23 2019-03 P1498R0 Evolution
P1502R0 Standard library header units for C++20 Richard Smith 2019-03-15 2019-03 Evolution, Library Evolution
P1505R0 Mandating the Standard Library: Clause 30 - Atomic operations library Daniel Sunderland 2019-03-10 2019-03 Library
P1517R0 Contract Requirements for Iterative High-Assurance Systems Ryan McDougall 2019-03-01 2019-03 Evolution
P1518R0 Stop overconstraining allocators in container deduction guides Arthur O'Dwyer, Mike Spertus 2019-03-10 2019-03 Library Evolution
P1520R0 Response to response to “Fibers under the magnifying glass” Gor Nishanov 2019-03-08 2019-03 SG1
P1601R0 Recommendations for Specifying “Hidden Friends” Walter E. Brown, Daniel Sunderland 2019-03-10 2019-03 Library Evolution, Library
P1602R0 Make Me A Module Nathan Sidwell 2019-03-01 2019-03 Evolution
P1604R0 The inline keyword is not in line with the design of modules. Corentin Jabot 2019-01-21 2019-03 Evolution
P1606R0 Requirements for Contract Roles Joshua Berne 2019-03-08 2019-03 Evolution
P1607R0 Minimizing Contracts Joshua Berne, Jeff Snyder 2019-03-08 2019-03 Evolution
P1609R0 C++ Should Support Just-in-Time Compilation Hal Finkel 2019-03-10 2019-03 Evolution Incubator
P1610R0 Rename await_resume() to await_result() Mathias Stearn 2019-03-10 2019-03 Library Evolution
P1611R0 WG21 2019-02 Kona Record of Discussion Nina Dinka Ranns 2019-03-10 2019-03 WG21
P1612R0 Relocate Endian's Specification Walter E. Brown, Arthur O’Dwyer 2019-03-10 2019-03 Library Evolution, Library
P1614R0 The Mothership Has Landed: Adding <=> to the Library Barry Revzin 2019-03-11 2019-03 Library
P1616R0 Using unconstrained template template parameters with constrained templates Mike Spertus, Roland Bock 2019-03-11 2019-03 Evolution
P1619R0 Functions for Testing Boundary Conditions on Integer Operations Lisa Lippincott 2019-03-10 2019-03 SG6, Library Evolution
P1622R0 Mandating the Standard Library: Clause 31 - Thread support library Daniel Sunderland 2019-03-10 2019-03 Library
P1625R0 Contracts: why the house is not on fire (i.e. why the status quo is tolerable) Ville Voutilainen 2019-03-11 2019-03 WG21

Interview with Bjarne Stroustrup invested Doctor Honoris Causa at University Carlos III of Madrid

On January 25th 2019, Bjarne Stroustrup was invested as Doctor Honoris Causa at University Carlos III of Madrid (Spain).

Honorary Doctorates are the highest honor that a Spanish Univeristy gives to somebody for their merit in the academic, scientific or artistic fields of activity.

Interview with Bjarne Stroustup

by Daniel Garcia

About the interview

In this short interview Dr. Stroustrup talks about the C++ programming language, the reasons that lead to its inception, its impact and other related topics.


Template meta-functions for detecting template instantiation—Ivan Čukić

Templates are great.

Template meta-functions for detecting template instantiation

by Ivan Čukić

From the article:

I’ve been playing around with type meta-tagging for my Voy reactive streams library (more on that some other time) and realized how useful it is to be able to check whether a given type is an instantiation of some class template, so I decided to write a short post about it...

Quick Q: What is a lambda expression in C++11?

Quick A: A convenient way to create a functor.

Recently on SO:

What is a lambda expression in C++11?

C++ includes useful generic functions like std::for_each and std::transform, which can be very handy. Unfortunately they can also be quite cumbersome to use, particularly if the functor you would like to apply is unique to the particular function.

#include <algorithm>
#include <vector>

namespace {
  struct f {
    void operator()(int) {
      // do something

void func(std::vector<int>& v) {
  f f;
  std::for_each(v.begin(), v.end(), f);

If you only use f once and in that specific place it seems overkill to be writing a whole class just to do something trivial and one off...

Understanding GCC warnings—Martin Sebor

In detail.

Understanding GCC warnings

by Martin Sebor

From the article:

Most of us appreciate when our compiler lets us know we made a mistake. Finding coding errors early lets us correct them before they embarrass us in a code review or, worse, turn into bugs that impact our customers. Besides the compulsory errors, many projects enable additional diagnostics by using the -Wall and -Wextra command-line options. For this reason, some projects even turn them into errors via -Werror as their first line of defense. But not every instance of a warning necessarily means the code is buggy. Conversely, the absence of warnings for a piece of code is no guarantee that there are no bugs lurking in it...

A gentle introduction to jump threading optimizations—Aldy Hernandez

Your complier does magic.

A gentle introduction to jump threading optimizations

by Aldy Hernandez

From the article:

As part of the GCC developers‘ on-demand range work for GCC 10, I’ve been playing with improving the backward jump threader so it can thread paths that are range-dependent. This, in turn, had me looking at the jump threader, which is a part of the compiler I’ve been carefully avoiding for years. If, like me, you’re curious about compiler optimizations, but are jump-threading-agnostic, perhaps you’ll be interested in this short introduction...