Quick Q: Setting a vector equal to {}
Quick A: It is possible.
Recently on SO:
Setting a vector equal to {};
It's valid (since C++11).
std::vector
has an overloaded operator= takingstd::initializer_list
.
June 16-21, Sofia, Bulgaria
September 13-19, Aurora, CO, USA
October 25, Pavia, Italy
November 6-8, Berlin, Germany
November 16-21, Kona, HI, USA
By Adrien Hamelin | Feb 11, 2020 12:40 PM | Tags: basics
Quick A: It is possible.
Recently on SO:
Setting a vector equal to {};
It's valid (since C++11).
std::vector
has an overloaded operator= takingstd::initializer_list
.
By Adrien Hamelin | Feb 11, 2020 12:35 PM | Tags: intermediate
How do you do it?
Various Ways of Applying a Function to the Elements of a Collection in C++
by Jonathan Boccara
From the article:
Applying a function to each element of a collection of object is a basic use case of manipulating collections, in C++ or anywhere else for that matter...
By Adrien Hamelin | Feb 11, 2020 12:31 PM | Tags: c++20
Concepts continued.
C++20: Define the Concept Regular and SemiRegular
by Rainer Grimm
From the article:
When you want to define a concrete type that works well in the C++ ecosystem, you should define a type that "behaves link an int". Formally, your concrete type should be a regular type. In this post, I define the concepts Regular and SemiRegular...
By Corentin Jabot | Feb 7, 2020 11:45 AM | Tags: c++23
SG-11, the study group charged of all things concurrency and parallelism made forward progress and sent the proposal to LEWG - with the hope of landing a future revision in the C++23 draft. This is rather big news given that this work has been brewing for about a decade.
A Universal I/O Abstraction for C++
by Corentin Jabot
From the article:
The year is 2020 and even consummer CPUs feature double digits number of cores, storage offers 10GB/s read speeds and networks have to accommodate ever-growing traffic.
For a long time, the C++ committee seemed to think that either async file I/O didn’t make sense or was fundamentally irreconcilable with networking. This belief would lead to two inter-incompatible APIs in the standard, which would be a nightmare in term of usability (aka ASIO and AFIO).
It seems that there is finally a way to resolve these divides:
io_uring offers very high performance I/O which doesn’t discriminate on device type.
Sender Receiver provides the composable, low-cost, non-allocating abstraction while offering a simple mental model for asynchronous operations lifetime.
Coroutines make asynchronous i/o dead simple for the 99% use case.
Asynchronous Networking is nice.Asynchronous I/O is better.
AWAIT ALL THE THINGS!
By Adrien Hamelin | Feb 4, 2020 02:29 PM | Tags: c++20
Getting familiar with concepts.
C++20 Concepts
by omnigoat
From the article:
A quick syntax-based overview of C++20 Concepts, as they are in the standard (circa January 2020)...
By Adrien Hamelin | Feb 4, 2020 02:28 PM | Tags: community
Don't miss it!
C++ in 2020
by Jens Weller
From the article:
Now where the year is a few weeks old, lets see whats ahead for C++ in 2020!
I'll cover the Meeting C++ Community Survey, Conferences, Libraries & Releases, ISOCPP and C++20.
This blog post is based on a newsletter, which is based on a talk I gave at my User Group in Düsseldorf two weeks ago. Come and visit our meetings at the 3rd Wednesday of the month! My C++ User Group is also still looking for speakers in 2020, contact me if you're in town!
By fj | Jan 31, 2020 05:20 AM | Tags: None
A taste of functional stack of effects.
Decorating with a side effect
by Krzysztof Ostrowski
From the article:
Logging is one of such overused features, that leads to costly side effects (consider distributed logging, a DLT, prevalent in automotive industry). This article describes a technique that is used to extract side effects brought by logging, and then compose with them back in a well defined manner.
By Adrien Hamelin | Jan 30, 2020 02:57 PM | Tags: c++20
The big ones.
C++20 Reference Card
by Bartlomiej Filipek
From the article:
While the C++20 Standard is still being finalised and polished, we know all of its core features. At first, the new specification of the language might sound complex and overwhelming. That’s why, if you want to have an overview of the core elements and get the bigger picture, you can have a look at my new reference card...
By Adrien Hamelin | Jan 28, 2020 02:04 PM | Tags: intermediate
Boolean and bit operators are not the same.
How to Short-Circuit a Sequence of Operations with a Boolean Value
by Jonathan Boccara
From the article:
Interrupting a sequence of operations when one of them fails is a common problem in computer programming. There are plenty of elaborate ways to code that, ranging from exceptions to monads to static exceptions.
One of the techniques to stop such a sequence of operations that is not so sophisticated, but that can be found in existing code, is to use a boolean. This relies on each step producing a boolean flag to indicate if it succeeded or failed, and to stop executing steps at the first failure.
However, simple as it is, this technique can lead to code that doesn’t do with it looks like...
By Adrien Hamelin | Jan 28, 2020 01:56 PM | Tags: experimental
Continuing on concepts.
C++20: Define the Concepts Equal and Ordering
by Rainer Grimm
From the article:
In my last post, I defined the concept Equal. Now, I go one step further and use the concept Equal to define the concept Ordering...