May 2023

The Case of string_view and the Magic String -- Giovanni Dicanio

Someone learned about std::string_view, and started replacing instances of std::string const& with string_views in their C++ code base. As a result of that, a subtle bug shows up!

The Case of string_view and the Magic String

by Giovanni Dicanio

From the article:

(...) The code is recompiled and executed. But, unfortunately, now the output has changed! What’s going on here? Where does that “magic string” come from?

Sign Up for the free Pure Virtual C++ 2023 Conference -- Sy Brand

PureVirtualC++.pngEvery year we run Pure Virtual C++: a free one-day virtual conference for the whole C++ community. Next month we’re doing it again! Sign-up for free to get access to our five live sessions and a host of pre-conference content.

Sign Up for the free Pure Virtual C++ 2023 Conference

by Sy Brand

From the article:

The live event will run June 6th 13:00-16:00 UTC. Videos will be available to stream for free on YouTube after the conference.

The live sessions will be:

  • C++ Compiler Errors for Humans with Sy Brand
  • Address Sanitizer continue_on_error with Jim Radigan
  • Value-Oriented Programming with Tony Van Eerd
  • Productive Cross-Platform and Game Development in Visual Studio with Sinem Akinci and David Li
  • Build Time Reflection with C++ in Year 2023 with Gabriel Dos Reis

 

Defining Interfaces in C++ with ‘Concepts’ (C++20) -- Daniel Lemire

In an earlier blog post, I showed that the Go programming language allows you to write generic functions once you have defined an interface.

Defining Interfaces in C++ with ‘Concepts’ (C++20)

by Daniel Lemire

From the article:

Java has a very similar concept under the same name (interface). I gave the following example:


	type IntIterable interface {

	    HasNext() bool

	    Next() uint32

	    Reset()

	}

	

	func Count(i IntIterable) (count int) {

	    count = 0

	    i.Reset()

	    for i.HasNext() {

	        i.Next()

	        count++

	    }

	    return

	}

CppCon 2023 Call for Submissions -- Daisy Hollman

From the CppCon.org website:

CppCon 2023 Call for Submissions

Posted on   by Daisy Hollman

CppCon is the annual, week-long (October 1st-6th, 2023) face-to-face gathering for the entire C++ community. The conference Main Program consists of five days of several concurrent tracks of sixty-minute sessions.

This conference is organized by the C++ Community for the C++ Community. We want the whole community to be represented. We especially encourage those who identify as coming from an underrepresented community to apply to present and to be present. Presenting a talk is not limited to previous presenters or previous attendees.

This year’s edition of CppCon will be onsite at the Gaylord Rockies in Aurora, Colorado.

Have you learned something interesting about C++, maybe a new technique possible in C++17/20/23? Or perhaps you have implemented something cool, maybe a new C++ library? Or perhaps have an idea for a future language or library feature that you want to advocate for? If so, consider sharing it with other C++ enthusiasts by giving a Main Program talk at CppCon 2023.

In the past year there has been great interest in C++ “evolution” or “successor” languages. These are an important part of today’s C++ community, and so CppCon 2022 had well-received talks about Val and other such experiments. These talks are in scope for CppCon 2023, as long as they are of interest to C++ developers and tied to C++ evolution and are not primarily talks about rewriting entire C++ codebases in something other than C++. For example, a talk on How to migrate your C++ code to Haskell is off-topic and will not be considered, but a talk on What C++ Programmers Can Learn from Swift, or What Rust Procedural Macros Might Look Like in C++, or Results of Val/Carbon/Circle Experiments That Could Be Incorporated Into ISO C++ Evolution are on-topic and will be considered.

The submission deadline is June 25th, with decisions sent by July 31st.

To facilitate a double-blind review process, please avoid statements in your abstract that remove all uncertainty about who you are. See examples on the Submissions page.

We plan to have most (if not all) of the same tracks as last year, and we would like to add a few more. Each track will put out a call for submissions as we confirm their participation. If you plan to submit to a track, please indicate in your submission which track(s) you’d expect your talk to fit into. If you have new ideas for tracks or special interest areas to better serve the C++ community, please get in touch with the program committee directly with your thoughts.

For talk topic ideas, possible formats, submission instructions and valuable advice on how to make the best possible submission, see the Submissions page.

Note: Calls for Lightning Talks and Open Content sessions will be made later this summer. The deadline for these is the conference itself.

 

CppCon 2022 How to Win at Coding Interviews -- David Stone

Stone-codinginterviews.pngRegistration is now open for CppCon 2023! The conference starts on October 1 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 2023!

Lightning Talk: How to Win at Coding Interviews

by David Stone

Summary of the talk:

5 minutes of preparation is plenty to beat any coding interview.

Consider Using constexpr Static Function Variables for Performance in C++ -- Daniel Lemire

When programming, we often need constant variables that are used within a single function.

Consider Using constexpr Static Function Variables for Performance in C++

by Daniel Lemire

From the article:

When programming, we often need constant variables that are used within a single function. For example, you may want to look up characters from a table. The following function is efficient:

char table(int idx) {
  const char array[] = {'z', 'b', 'k', 'd'};
  return array[idx];
}

HPX V1.9.0 released -- STE||AR Group

The STE||AR Group has released V1.9.0 of HPX -- A C++ Standard library for Concurrency and Parallelism.

HPX V1.9.0 Released

We have released HPX 1.9.0 — a major update to our C++ Standard Library for Concurrency and Parallelism. The HPX parallel algorithms now have been fully adapted to C++23, all existing facilities have been adjusted to conform to this version of the Standard as well. We now can proudly announce full conformance to the C++23 concurrency and parallelism facilities. HPX supports all of the parallel algorithms as specified by C++23. We have been able to significantly improve the performance of some of our algorithms. On top of that we support parallel versions of all range-based algorithms and have added more support for explicit vectorization to our algorithms (using std::experimental::simd). Even more work has been done towards implementing P2300 (std::execution) and keeping the underlying senders/receivers facilities in line with the evolving standardization efforts. We have done a lot of refactoring to improve the consistency of our exposed APIs. Last but not least, we have continued to improve our documentation, please have a look here.

If you have any questions, comments, or exploits to report you can reach us on IRC or Matrix (#ste||ar on libera.chat) or email us at hpx-users. We depend on your input!

You can download the release from our releases page or check out the v1.9.0 tag using git. A full list of changes can be found in the release notes.

HPX is a general-purpose parallel C++ runtime system for applications of any scale. It implements all of the related facilities as defined by the C++20 Standard. As of this writing, HPX provides the only widely available open-source implementation of the new C++17, C++20, and C++23 parallel algorithms, including a full set of parallel range-based algorithms. Additionally, HPX implements functionalities proposed as part of the ongoing C++ standardization process, such as large parts of the features related parallelism and concurrency as specified by the upcoming C++23 Standard, the C++ Concurrency TS, Parallelism TS V2, data-parallel algorithms, executors, and many more. It also extends the existing C++ Standard APIs to the distributed case (e.g., compute clusters) and for heterogeneous systems (e.g., GPUs).

HPX seamlessly enables a new Asynchronous C++ Standard Programming Model that tends to improve the parallel efficiency of our applications and helps reducing complexities usually associated with parallelism and concurrency.

 

CppCon 2022 How C++23 Changes the Way We Write Code -- Timur Doumler

Cpp22-Doumler.pngRegistration is now open for CppCon 2023! The conference starts on October 1 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 2023!

How C++23 Changes the Way We Write Code

by Timur Doumler

Summary of the talk:

C++20 was a huge release: coroutines, concepts, ranges, and modules profoundly changed the way we write code and think about C++. In comparison, C++23 is a lot smaller in scope: its primary mission is to complete C++20, to fill holes, and to fix issues. Nevertheless, some great new features made the cut this time around, both in the standard library and in the core language. This is even more remarkable considering that the entire feature design phase of C++23 took place during the COVID-19 pandemic, challenging the ISO C++ committee to completely reinvent how we work together.

This is not a firehose talk about C++23 that tries to cram as many additions and improvements as possible into one hour. Instead, we deliberately focus on just a handful of new features that are going to noticeably change and improve the experience of the everyday C++ programmer. We will talk about how `std::expected` improves error handling, the huge impact that `std::mdspan` will have on scientific computing, how deducing `this` greatly simplifies longstanding C++ idioms such as CRTP, and how `std::print` will forever change how we write "Hello, World".

ISO C++ Feb 2023 meeting trip report (core language) -- Jason Merrill

The C++ committee had its second hybrid meeting in Issaquah, WA in February, to finalize C++23. This was also the venue where we finished up C++14.

ISO C++ Feb 2023 meeting trip report (core language)

by Jason Merrill

From the article:

The C++ committee had its second hybrid meeting in Issaquah, WA in February, to finalize C++23.  This was also the venue where we finished up C++14.  I was there in person from Red Hat, while Thomas Rodgers and Jonathan Wakely attended virtually.  As usual, I spent most of my time in the Core working group.

The primary goal of the meeting was to finish responding to national body comments on the draft and advance the result for balloting to become C++23, and indeed we did; the week went smoothly from my perspective.  We also spent a fair amount of time reviewing papers and issues that were not expected to go into C++23.

Most of the C++23 fixes at this meeting were unremarkable, but a couple are worth mentioning:

CWG2518 clarifies that...

Functional Programming in C++ -- John Carmack

A classic, over a decade old and worth making the rounds again:

Functional Programming in C++

by John Carmack

From the article:

My pragmatic summary: A large fraction of the flaws in software development are due to programmers not fully understanding all the possible states their code may execute in. ... No matter what language you work in, programming in a functional style provides benefits.  You should do it whenever it is convenient, and you should think hard about the decision when it isn’t convenient.

... C++ doesn’t encourage functional programming, but it doesn’t prevent you from doing it, and you retain the power to drop down and apply SIMD intrinsics to hand laid out data backed by memory mapped files, or whatever other nitty-gritty goodness you find the need for. ...