Bjarne Stroustrup - Meeting C++ 2016 Keynote: What C++ is and what it will become
Since yesterday this years opening keynote by Bjarne Stroustrup is on youtube:
What C++ is and what it will become
by Bjarne Stroustrup
October 25, Pavia, Italy
November 6-8, Berlin, Germany
November 3-8, Kona, HI, USA
By Meeting C++ | Dec 5, 2016 02:51 AM | Tags: modules efficiency concepts c++20 c++17 c++14 c++11 basics advanced
Since yesterday this years opening keynote by Bjarne Stroustrup is on youtube:
What C++ is and what it will become
by Bjarne Stroustrup
By Jason Turner | Nov 29, 2016 09:52 AM | Tags: c++17 advanced
Episode 39 of C++ Weekly.
C++17's Deduction Guides
by Jason Turner
About the show:
C++17's automatic class template deduction feature brings with it a new sub-feature called "deduction guides" which are used to help the compiler with class template type deduction. Jason gives examples of what they are and how they are used in this episode.
By Adrien Hamelin | Nov 28, 2016 12:33 PM | Tags: experimental advanced
With the next version of C++.
Compose and curry as folds
by Nick Athanasiou
From the article:
In a previous post we introduced C++17 fold expressions and described a way to extend them for arbitrary callables. Implementation details don’t matter for what we’re elaborating on here but it should be clear that (given the tools we developed) the following is possible:
(Op<F>(args) + ...) (... + Op<F>(args))
By Adrien Hamelin | Nov 11, 2016 12:54 PM | Tags: performance advanced
A very interesting article about the cost of our basic operations.
Infographics: Operation Costs in CPU Clock Cycles
by “No Bugs” Hare
From the article:
Whenever we need to optimise the code, we should profile it, plain and simple. However, sometimes it makes sense just to know ballpark numbers for relative costs of some popular operations, so you won’t do grossly inefficient things from the very beginning (and hopefully won’t need to profile the program later )...
By Adrien Hamelin | Nov 7, 2016 12:02 PM | Tags: advanced
Do you know how a program ends?
Terminators
by Adi Shavit
From the article:
A GraphViz diagram that shows both normal and unexpected program termination flows in C++.
There are multiple ways a C++ program may terminate. These include both normal and unexpected termination.
This GraphViz diagram shows the program termination flows as defined by the standard...
By Adrien Hamelin | Nov 4, 2016 01:09 PM | Tags: experimental advanced
An introduction to the world of C++17.
checking expression validity in-place with C++17
by Vittorio Romeo
From the article:
When writing generic code, it is sometimes useful to check whether or not a particular SFINAE-friendly expression is valid (e.g. to branch at compile-time). Let's assume that we have the following class declarations...
struct Cat { void meow() const { cout << "meow\n"; } }; struct Dog { void bark() const { cout << "bark\n"; } };...and that we would like to write a template function
make_noise(x)that callsx.meow()and/orx.bark()if they are well-formed expressions:template <typename T> void make_noise(const T& x) { // Pseudocode: /* if(`x.meow()` is well-formed) { execute `x.meow();` } else if(`x.bark()` is well-formed) { execute `x.bark();` } else { compile-time error } */ }In this article I'll show how to implement the pseudocode in:
C++11: using
std::void_tandstd::enable_if.C++14: using
boost::hana::is_validandvrm::core::static_if.C++17: using
if constexpr(...), constexpr lambdas, andstd::is_callable. This version will allow expression validity to be checked in-place (i.e. directly in the if constexpr predicate). Variadic preprocessor macros will also be used to make the user code easier to read and maintain...
By Adrien Hamelin | Nov 1, 2016 12:04 PM | Tags: c++11 advanced
Quick A: There are several special cases where you may want that, but in general no.
Recently on SO:
Is there a case where ellipsis(vararg) should be preffered over variadic templates?
- If you provide a C API with C++ implementation, then templates are not an option for the API. Varargs are.
- If you need to support a compiler that doesn't support C++11 or newer standard, then variadic templates are not available. Varargs are.
- If you need a compilation firewall. I.e. you need to hide the implementation of the function from the header, then variadic template is not an option. Varargs are.
- On memory constrained systems (embedded), the different functions generated by the template may introduce too much bloat. That said, such systems are typically also real time, in which case varargs might also unacceptable due to branching and stack usage.
By Adrien Hamelin | Oct 27, 2016 11:47 AM | Tags: c++11 advanced
Or how to improve readability and reduce errors.
void foo(T& out) - How to fix output parameters
by Jonathan Müller
From the article:
There are some cases where you need to return a value from a function but cannot use the return value. It happens, for example, in functions where you want to return multiple values at once. While you can pass multiple inputs to a function - the parameters, you cannot pass multiple return values in the same way.
C++ programmers tend to use a good old (lvalue) reference for that. You take a non-const reference as parameter and assign the output to that reference. The caller will pass a variable and upon function completion find the value of the variable changed.
Yet this approach has some problems: For starters, it is not obvious when just looking at the call that the variable is going to be changed. This is the reason that C++ style guides such as the one used by Google recommend using a pointer for that. The caller then has to explicitly pass in the address of the variable, making it explicit.
But with a pointer you can now pass in nullptr, you have to check for that in the function: A pointer where you really mean “reference” does not follow the guidelines I’ve been advocating for.
So is there not a universal solution?
There is, but first we need to understand the full scope of the problem.
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 Ábel Sinkovics | Oct 4, 2016 05:37 AM | Tags: advanced
Metashell provides a compile-time debugger for debugging template instantiations and macro usage.
Metashell 3.0.0 is available
From the website:
Some of the major new features in 3.0.0:
- Profiling template instantiations
- Debugging template instantiations in expressions involving SFINAE
- Displaying preprocessed expressions
Commands for exploring the available headers (similar to the which and ls commands).
The full list of changes can be found here.An online demo can be found at http://metashell.org/about/demo/
Installers can be downloaded from http://metashell.org/getting_metashell/installers#version-300