November 2016

Infographics: Operation Costs in CPU Clock Cycles--“No Bugs” Hare

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 �� )...

CppCast Episode 78: Kvasir with Odin Holmes

Episode 78 of CppCast the only podcast for C++ developers by C++ developers. In this episode Rob and Jason are joined by Odin Holmes to talk about developing for Embedded Microcontrollers with C++ and the Kvasir library.

CppCast Episode 78: Kvasir with Odin Holmes

by Rob Irving and Jason Turner

About the interviewee:

Odin Holmes has been programming bare metal embedded systems for 15+ years and as any honest nerd admits most of that time was spent debugging his stupid mistakes. With the advent of the 100x speed up of template metaprogramming provided by C++11 his current mission began: teach the compiler to find his stupid mistakes at compile time so he has more free time for even more template metaprogramming. Odin Holmes is the author of the Kvasir.io library, a DSL which wraps bare metal special function register interactions allowing full static checking and a considerable efficiency gain over common practice. He is also active in building and refining the tools need for this task such as the brigand MPL library, a replacement candidate for boost.parameter and a better public API for boost.MSM-lite.

GoingNative 53: Learning STL Multithreading--Steve Carroll, Augustin Popa and BryanDiLaura

The new GoingNative is out!

GoingNative 53: Learning STL Multithreading

by Steve Carroll, Augustin Popa and BryanDiLaura

From the video:

In this episode, Billy O'Neal and Stephan T. Lavavej (S.T.L.) talk about the Standard Template Library for multithreading, and how to use it properly. We would love to hear some feedback on this episode! If you liked it, let us know and we may make a follow up!

Terminators--Adi Shavit

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...

Why you should use Boost.MultiIndex (Part I)--David Gross

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.

Collaborative Online Compilers

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++...

Compiler Explorer's embedded view--Matt Godbolt

An interesting tool:

Compiler Explorer's embedded view

by Matt Godbolt

From the article:

Today I updated Compiler Explorer to support better sharing, specifically to allow embedding a Compiler Explorer view into another site, useful for blog posts that wish to demonstrate how compilers generate code, or how language constructs actually become assembly...

checking expression validity in-place with C++17--Vittorio Romeo

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 calls x.meow() and/or  x.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_t and std::enable_if.

C++14: using boost::hana::is_valid and vrm::core::static_if.

C++17: using if constexpr(...), constexpr lambdas, and std::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...

Getting your head around auto’s type-deduction rules--Glennan Carnie

Are the rules clear to you?

Getting your head around auto’s type-deduction rules

by Glennan Carnie

From the article:

Automatic type-deduction is perhaps one of the more divisive features of Modern C++.  At its core it’s a straightforward concept:  let the compiler deduce the type of an object from its initialiser.   Used in the right way this can improve the readability and maintainability of your code.

However, because auto is based on template type-deduction rules there are some subtleties that can catch the unwary programmer.

In this article we’ll have a look at auto in the context of the template type-deduction rules to see where all these subtleties come from...