C++ Weekly Episode 37: Stateful Lambdas—Jason Turner
Episode 37 of C++ Weekly.
Stateful Lambdas
by Jason Turner
About the show:
In this episode Jason demonstrates how stateful lambdas can be created using features from C++14.
February 10-15, Hagenberg, Austria
March 19-21, Madrid, Spain
April 1-4, Bristol, UK
June 16-21, Sofia, Bulgaria
By Jason Turner | Nov 14, 2016 11:12 AM | Tags: c++14 basics
Episode 37 of C++ Weekly.
Stateful Lambdas
by Jason Turner
About the show:
In this episode Jason demonstrates how stateful lambdas can be created using features from C++14.
By Meeting C++ | Nov 7, 2016 03:44 AM | Tags: experimental basics
I was doing some research on possible live formats...
Collaborative Online Compilers
by Jens Weller
From the article:
While doing some brainstorming for possible (youtube) live formats with C++ content, the thought of having a shared online IDE/Compiler came into my mind. Think of Google Docs but for C++...
By Meeting C++ | Nov 4, 2016 03:46 AM | Tags: intermediate c++11 basics
A blogpost on how I randomized the student selection for Meeting C++ 2016
Randomizing a CSV File with Standard C++
by Jens Weller
From the article:
For this years student program I had to come up with a way to randomly select n students from all applicants. I wanted to do this in a clean and nice C++ program. So here it is...
By Adrien Hamelin | Oct 18, 2016 01:42 PM | Tags: basics
Are you clear with unsigned?
The “unsigned” Conundrum
by Tony “Bulldozer00” DaSilva
From the article:
A few weeks ago, CppCon16 conference organizer Jon Kalb gave a great little lightning talk titled “unsigned: A Guideline For Better Code“. Right up front, he asked the audience what they thought this code would print out to the standard console:
Even though -1 is obviously less 1, the program prints out “a is not less than b“. WTF?
By Meeting C++ | Oct 11, 2016 05:57 AM | Tags: intermediate efficiency deep learning cuda basics advanced
Today a new version of DLib is available:
DLib 19.2 released
Release notes
by Davis King
From the article:
... So the obvious thing to do was to add an implementation of MMOD with the HOG feature extraction replaced with a convolutional neural network. The new version of dlib, v19.2, contains just such a thing. On this page you can see a short tutorial showing how to train a convolutional neural network using the MMOD loss function. It uses dlib's new deep learning API to train the detector end-to-end on the very same 4 image dataset used in the HOG version of the example program. Happily, and very much to the surprise of myself and my colleagues, it learns a working face detector from this tiny dataset.
By Adrien Hamelin | Oct 10, 2016 12:22 PM | Tags: c++11 basics
Quick A: Yes.
Recently on SO:
Is the 'override' keyword just a check for a overriden virtual method?
That's indeed the idea. The point is that you are explicit about what you mean, so that an otherwise silent error can be diagnosed:
struct Base { virtual int foo() const; }; struct Derived : Base { virtual int foo() // whoops! { // ... } };The above code compiles, but is not what you may have meant (note the missing
const
). If you said instead,virtual int foo() override
, then you would get a compiler error that your function is not in fact overriding anything.
By Adrien Hamelin | Sep 29, 2016 11:47 AM | Tags: c++11 basics
Quick A: No, at worse it will be a move.
Recently on SO:
Initializing a std::string with function return value, is there a copy?
In general, if the std::string is constructed in the call and then returned most modern compilers with apply the return value optimization (a special case of copy elision). Your case in particular is the Named RVO (thanks @NathanOliver for pointing this out), if you want to look up the precise rules. From C++17 on this optimization is guaranteed through the standard.
Whether or not the optimization is applied is hard to tell, however if it is not, then in C++11 and above it is very likely that the std::string object in the scope of the function will be moved from and that the return value will be moved to. You could theoretically call std::move on the return value, but thereby you would also prevent any RVO from happening. While move may be efficient, RVO typically yields faster code, because nothing is moved or copied at all, but the object is constructed in place, so I would advise against doing it, and in favor of relying on your compiler.
By Jason Turner | Sep 26, 2016 03:32 PM | Tags: c++17 basics
Episode 30 of C++ Weekly.
C++17's [[nodiscard]] Attribute
by Jason Turner
About the show:
Wrapping up C++ Weekly's C++17 attribute coverage with possibly the most interesting yet: [[nodiscard]].
By Jason Turner | Sep 16, 2016 01:26 PM | Tags: c++17 basics
Episode 28 of C++ Weekly.
C++17's [[fallthrough]] Attribute
by Jason Turner
About the show:
Understanding the new [[fallthrough]] attribute added in C++17 through examples.
By Andrey Karpov | Sep 15, 2016 05:11 AM | Tags: c++17 c++11 basics
One of the main problems with C++ is having a huge number of constructions whose behavior is undefined, or is just unexpected for a programmer. Let's see which techniques in modern C++ help writing not only simple and clear code, but make it safer and more reliable.
How to avoid bugs using modern C++
by Pavel Belikov
From the article:
Of course, there are some flaws in the range-based for: it doesn't allow flexible management of the loop, and if there is more complex work with indexes required, then for won't be of much help to us. But such situations should be examined separately. We have quite a simple situation: we have to move along the items in the reverse order. However, at this stage, there are already difficulties. There are no additional classes in the standard library for range-based for. Let's see how it could be implemented.