advanced

Cheerp PreExecuter: compile-time evaluation of constructors--Sander Mathijs van Veen

An advancement in the world of C++ to javascript:

Cheerp PreExecuter: compile-time evaluation of constructors

by Sander Mathijs van Veen

From the article:

The size of a JavaScript web application, especially when compiled from a complex C++ source, has a key role on the quality of the user experience, being directly connected to the download and startup time. Size also has a big impact on the traffic and bandwidth needs of the hosting server, which translates one to one into costs. Therefore, minimizing the size of JavaScript applications compiled from C++ with Cheerp has always been one of our priorities...

Notes on C++ SFINAE -- Bartlomiej Filipek

Bartlomiej explains in his recent blog post in nice details the SFINAE construct.

Notes on C++ SFINAE

by Bartlomiej Filipek

From the article:

This time I’d like to tackle a bit more complex problem: SFINAE. I’m not using this paradigm on a daily basis, but I’ve stumbled across it several times and I thought it might be worth trying to understand this topic.

What is SFINAE? Where can you use it? Do you need this on a daily basis? Let’s try to answer those questions.

In the article he goes into details of Overload Resolution, Where can I use it?, enable_if, Expression SFINAE, Any disadvantages?, and Alternatives to SFINAE.

Revisiting QWidgets & data, refactoring and performance

A follow up on an older Blog post of mine:

Revisiting QWidgets & data, refactoring and performance

by Jens Weller

From the article:

My CMS project has grown quite a bit, and there are a few places where I think I should refactor the code. One of the larger ones is that TreeItem::get<T> returns a pointer instead of a reference. Another one is related to how the Qt UI application is acting when opening a new panel in the TabControl. There used to be a noticeable delay...

Searching and replacing in strings with boost

My series on building applications with Qt an boost continues:

Searching and replacing in strings with boost

by Jens Weller

From the article:

The next big milestone for my CMS is to actually generate HTML files, and I'm almost there. I'll reach it in the next two weeks, most code is written, just a little bit of refactoring is needed. This blog post is about searching and replacing in strings. As I started last week with implementing the functionality, that turns the data in my CMS into an HTML website.

There needs to be a lot of text transformed, in order to turn a shared structure like a cross page layout into a single, special HTML file, one of those transformations is, to replace the internal links with the correct links. A link to a different page in the same website cannot be represented as a text link, instead it is represented by a linkid, which corresponds to the Page it points to. This is to have still the correct link, if the page is renamed or moved...

Overload 131 is now available

ACCU’s Overload journal of February 2016 is out. It contains the following C++ related articles.

Overload 131

From the journal:

Defining Concepts
Concepts provide a new way of constraining code. Andrew Sutton shows us how to define and use them. by Andrew Sutton

On Zero-Side-Effect Interactive Programming, Actors, and FSMs
Functional programming is alien to many programmers. Sergey Ignatchenko considers parallels between actors and finite state machines.

Template Programming Compile Time Combinations & Sieves
Functional style frequently uses sequences. Nick Weatherhead applies these ideas to combinations in C++. by Nick Weatherhead

Classdesc: A Reflection System for C++11
C++ lacks direct support for reflection. Russell Standish brings an automated reflection system for C++, Classdesc, up to date. by Russell Standish

QM Bites : Maximising Discoverability of Virtual Methods
C++11 introduced override as a contextual keyword. Matthew Wilson encourages us to use it. by Matthew Wilson

So Why is Spock Such a Big Deal?
Spock testing in a Java environment is all the rage. Russel Winder talks through the history of testing on the JVM and demonstrates why Spock is so groovy. by Russel Winder

Fundamentals of Type-Dependent Code Reuse - Mark Isaacson - NDC Oslo 2015

From NDC Oslo 2015:

Fundamentals of Type-Dependent Code Reuse

by Mark Isaacson

About the video:

This talk surveys different code reuse problems that can be solved by leveraging type information. Mark talks about how you can optimize your algorithms so that certain types use a "fast path", all while hiding that complexity from your users. He also talks about various ways to create "opt-in" functions for your classes. The talk is accessible to novices but builds gradually to complex ideas, including a theoretical C++17 "Mixer" class that allows users to add arbitrary functions to any type, including ints, on an instance by instance granularity.

Emulating C++17 Structured Bindings in C++14--John Bandela

How to use tuple return values with ease?

Emulating C++17 Structured Bindings in C++14

by John Bandela

From the article:

Bjarne Stroustrup back in Novemeber wrote a nice progress report, available here, of the Kona meeting. One of the proposals considered is called structured binding. The proposal addresses one of the inconveniences of returning multiple values from a function using tuples. While, it is very easy for a function to return multiple values, it is harder for the caller to use them. Here is an example from the write up.

consider the following function

tuple<T1,T2,T3> f() { /*...*/ return make_tuple(a,b,c); }

If we want to split the tuple into variables without specifying the type, we have to do this;

auto t = f();
auto x = get<1>(t);
auto y = get<2>(t);
auto z = get<3>(t);

The proposal puts forth the following syntax instead

auto {x,y,z} = f();               // x has type T1, y has type T2, z has type T3

I am excited for this feature, and for C++17 in general. While waiting for C++17, I decided to see how close I could get with C++14. Here is the result.

auto r = AUTO_TIE(x,y,z) = f();               // x has type T1, y has type T2, z has type T3

// Unlike the C++17 feature, you need to use r.x instead of just x
std::cout << r.x << "," << r.y << "," << r.z << "\n";