Stupid C++ namespace tricks--Raymond Chen
Stupid but useful.
Stupid C++ namespace tricks
by Raymond Chen
From the article:
These tricks may be obvious, but at least I'm going to write them down...
By Adrien Hamelin | May 22, 2018 01:32 PM | Tags: intermediate
Stupid but useful.
Stupid C++ namespace tricks
by Raymond Chen
From the article:
These tricks may be obvious, but at least I'm going to write them down...
By Adrien Hamelin | May 22, 2018 01:10 PM | Tags: c++17 advanced
Evolution of semantics.
Rvalues redefined
by Andrzej Krzemieński
From the article:
In this post we will explore what I consider the most significant language change in C++17. I call it the most significant because it changes the way you design your resource-managing types and how you think about initialization. It is often called “guaranteed copy elision”, but I will not use that name (except for this single time) because it does not reflect what this feature is. C++ has completely changed the meaning of rvalue (actually, prvalue)...
By Adrien Hamelin | May 22, 2018 01:04 PM | Tags: stl intermediate
Old vs new.
std::accumulate vs. std::reduce
by Simon Brand
From the article:
std::accumulate has been a part of the standard library since C++98. It provides a way to fold a binary operation (such as addition) over an iterator range, resulting in a single value. std::reduce was added in C++17 and looks remarkably similar. This post will explain the difference between the two and when to use one or the other...
By Adrien Hamelin | May 21, 2018 12:19 PM | Tags: intermediate c++17
Make our life simpler.
Overload: Build a Variant Visitor on the Fly
by Arne Mertz
From the article:
Having written about std::variant and std::visit last week, it’s time to string together some modern C++ features to build a naive basic implementation of overload, a proposed C++ feature...
By Adrien Hamelin | May 21, 2018 12:17 PM | Tags: advanced
The next part.
How to Make SFINAE Pretty – Part 2: the Hidden Beauty of SFINAE
by Jonathan Boccara
From the article:
As we’ve seen in How to Make SFINAE Pretty – Part 1: What SFINAE Brings to Code, SFINAE in code is as pretty as a windmill in a field. That is, not very pretty.
But like a windmill, it’s useful. SFINAE helps deactivate a piece of template code depending on a condition, and that can be very convenient...
By Adrien Hamelin | May 21, 2018 12:16 PM | Tags: advanced
New series!
How to Make SFINAE Pretty – Part 1: What SFINAE Brings to Code
by Jonathan Boccara
From the article:
SFINAE is a bit like a windmill. It sits as a wart in the middle of an interface, BUT it’s useful to create elaborate static polymorphism, in particular before C++17 and if constexpr, and even in some use cases in C++17.
I thought we had to live with this tradeoff, until I watched a talk from Stephen Dewhurst at CppCon. In this inspring talk, Stephen shows how to turn SFINAE around to make it very expressive in an interface. Watching this talk changed my way of coding template interfaces...
By Adrien Hamelin | May 18, 2018 11:19 AM | Tags: community advanced
What do you think?
Default-constructibility is overrated
by Arthur O’Dwyer
From the article:
The Ranges Technical Specification includes very many concept definitions (based on the Concepts TS), including for example Integral and Predicate. It also provides a concept named Regular which implements a variation on the “Regular” concept described by Alexander Stepanov in his paper '’Fundamentals of Generic Programming’’ (1998)...
By Adrien Hamelin | May 18, 2018 11:15 AM | Tags: intermediate
Quick A: Don't hide pointers in typedefs.
Recently on SO:
typedef pointer const weirdness
Note that
typedef int* intptr; const intptr x;is not the same as:
const int* x;intptr is pointer to int. const intptr is constant pointer to int, not pointer to constant int.
so, after a typedef pointer, i can't make it const to the content anymore?
There are some ugly ways, such as gcc's typeof macro:
typedef int* intptr; intptr dummy; const typeof(*dummy) *x;but, as you see, it's pointless if you know the type behind intptr.
By Adrien Hamelin | May 18, 2018 11:12 AM | Tags: community
New trip report!
Back to Aspen: C++Now trip report by JetBrains
by Anastasia Kazakova and Phil Nash
From the article:
In May we were back to Aspen for C++Now 2018. This year the weather in Aspen was very friendly (no snowstorm like in 2017) and we were enjoying every single day of the event.
By bfilipek | May 16, 2018 12:27 PM | Tags: c++17
We waited 15 years for the second edition... and finally it's there!
C++ Templates - The Complete Guide 2nd Book Review
by Bartlomiej Filipek
From the article:
An epic book that will fill a lot of your time and will leave you with solid knowledge about modern C++ templates (including C++11, C++14 and C++17… and even some insight about upcoming things in C++20).