Lambda Magic ✨ -- Adi Shavit
Are C++ lambdas magical?
Lambda Magic ✨
by Adi Shavit
From the article:
"Like fairies, captureless lambdas are pure and magical creatures.
Unlike fairies, captureless lambdas can be converted to function pointers."
March 23-28, London, UK
By Adi | Nov 21, 2016 11:35 PM | Tags: None
Are C++ lambdas magical?
Lambda Magic ✨
by Adi Shavit
From the article:
"Like fairies, captureless lambdas are pure and magical creatures.
Unlike fairies, captureless lambdas can be converted to function pointers."
By Mantosh Kumar | Nov 21, 2016 10:34 PM | Tags: performance efficiency
Discussion on how we can efficiently use std::vector<T> container.
6 Tips to supercharge C++11 vector performance
by Deb Haldar
From the article:
Vector is like the swiss army knife of C++ STL containers. In the words of Bjarne Stroutsoup – “By default, use Vector when you need a container”. For mere mortals like us, we take this as gospel and just run with it. However, Vector is just a tool and like any tool, it can be used both effectively or ineffectively.
In this article we’ll look at 6 ways to optimize usage of vectors. We’ll look at both efficient and inefficient ways to perform the most common programming tasks using vectors, measure the performance gain we obtain by using vectors efficiently and try to understand why we’re getting the performance gain.
By Mantosh Kumar | Nov 21, 2016 09:44 PM | Tags: None
Discussion on "Distinguish between () and {} when creating objects".
![]()
Help me sort out the meaning of "{}" as a constructor argument
by Scott Meyers
From the article:
My experiments showed that one factor affecting whether "{{}}" as an argument list yields a zero-length std::initializer_list<T> was whether T had a default constructor, so I threw together some test code involving three classes, two of which could not be default-constructed. I then used both "({})" (note the outer parentheses) and "{{}}" as argument lists to a constructor taking a std::initializer_list for a template class imaginatively named X. When the constructor runs, it displays the number of elements in its std::initializer_list parameter.
By fj | Nov 14, 2016 02:34 AM | Tags: None
C++11 re-introduces auto keyword that enables basic type inference. Using auto not only improves code readability.
When type inference fails
by Krzysztof Ostrowski
From the article:
Use of type inference puts impact on what is possible to be done with certain value, i.e. on its interface or concept it models, rather than on its concrete type. Unfortunately,
autodoes type inference locally, thus is not such powerful as we might expect. Here follows some examples ofauto-inference failures.
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 9, 2016 01:18 PM | Tags: intermediate c++11
Variadics explained:
Modern C++ Features – Variadic Templates
by Arne Mertz
From the article:
Generic programming and metaprogramming with templates always have been one of the features that set C++ apart from most other languages. With C++11, variadic templates added even more possibilities in that area to the language...
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 7, 2016 11:56 AM | Tags: community boost
Did you know that container?
Why you should use Boost.MultiIndex (Part I)
by David Gross
From the article:
Although Boost.MultiIndex is a pretty old library — introduced in Boost 1.32, released in 2004 — I found it rather unsung and underestimated across the C++ community in comparison to other non-standard containers.
In this article, split into multiple parts, I will highlight all the benefits you can get using boost::multi_index_container instead of the standard containers: faster, cleaner and simpler code.
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 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...