Compiler improvements in VS 2015 Update 2—Andrew Pardoe

The C++ compiler team is excited for you to try out the compiler in Visual Studio 2015 Update 2 CTP 1. Let’s dive into some of the feature improvements they have made in the compiler for Update 2:

Compiler improvements in VS 2015 Update 2

by Andrew Pardoe

From the article:

Since Update 1 we’ve made progress on being Standards-conformant for lot of C++11 and C++14 features...

A bit of background for the structures bindings proposal

[This note from Bjarne provides some background for the updated structured bindings proposal posted yesterday. --Ed.]


In the context of the C++ Core Guidelines, we (Herb Sutter, Gabriel Dos Reis, me, and few others) were discussing sources of bugs and inefficiencies. We noticed that returning multiple values (e.g., from a tuple) was one of the two remaining sources of uninitialized variables. We noticed that there were real cases of bugs and inefficiency (from default initialization followed by assignment rather than initialization) stemming from separating variable introduction from initialization. Use of tie() is at best a partial solution that doesn’t get to the root of the problem.

The next day or so, Herb had a first draft of a proposal. We refined it, adding use cases and implications. I noted that we had a syntax in concepts for the introduction of multiple names that we could borrow. We noted that whatever we came up with had to fit into our ideas for a possible future far-more-general pattern matching design. We always try to ensure that a proposal doesn’t block an important potential evolution path. The design document for the proposal was refined and extended.

It was now obvious that the proposal completed C++’s mechanism for returning multiple values from a function: With structured binding, we can initialize a set of values, {x,y,z},  just as we  can return a set of values, {e1,e2,e3}.

In web discussions, and especially at the Kona standards meeting, many alternatives were discussed. We focused on how to deal with user-defined types with private members. The new feature mustn’t discourage encapsulation by providing a convenient notation for structs only. We also considered whether explicit declaration of types were needed and how to achieve conversions. A conversion from a char[] in a return value to a string was considered particularly desirable by several people. These two needs were both addressed by adding the ability for users to define get<N> functions for a class. Jens Maurer refined the proposed wording and in doing so found a few weaknesses in the design.

For the details and code examples, you can find the current proposal and wording papers here for the upcoming meeting in Jacksonville.

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

Modern C++ features: in-place construction—Arne Mertz

And emplace_back function:

Modern C++ features: in-place construction

by Arne Mertz

From the article:

Move constructors are often cheaper than copy constructors, which makes the construction and immediate relocation of objects in modern C++ more effective than in C++03. However, just moving the parts needed to construct the object in the right place can be even more effective. Several standard library functionalities use perfect forwarding to construct objects right where they are needed.

CppCast Episode 44: HPC and more with Bryce Lelbach

Episode 44 of CppCast the only podcast for C++ developers by C++ developers. In this episode Rob and Jason are joined by Bryce Lelbach to discuss High Performance Computing and other C++ topics.

CppCast Episode 44: HPC and more with Bryce Lelbach

by Rob Irving and Jason Turner

About the interviewee:

Bryce Adelstein Lelbach is a researcher at Lawrence Berkeley National Laboratory (LBNL), a US Department of Energy research facility. Working alongside a team of mathematicians and physicists, he develops and analyzes new parallel programming models for exascale and post-Moore architectures. Bryce is one of the developers of the HPX C++ runtime system; he spent five years working on HPX while he was at Louisiana State University's Center for Computation and Technology. He also helped start the LLVMLinux initiative, and has occasionally contributed to the Boost C++ libraries. Bryce is an organizer for C++Now and CppCon conferences and he is passionate about C++ community development. He serves as LBNL's representative to the C++ standards committee.

C++ track at NDC Oslo 2016, June 6-10 (CFP ends Feb 15)

For the third year in a row we will set up a strong C++ track at the NDC conference in Oslo, June 6-10. 

   The Call for Paper ends February 15   

At NDC Oslo the typical crowd of 2000+ developers can choose from 9-10 parallel tracks over 3 long days (June 8-10). One of these tracks will be about C++, but there will be tracks on embedded programming, security and IoT just to mention a few. There are also many preconference 2-day tutorials/workshops (June 6-7) and several of these will be on C++ and C (stay tuned).

We have already signed up several solid C++ speakers. Anthony Williams, Mark Isaacson, Hubert Matthews, Dan Saks, Andrei Alexandrescu, will be there. Will you? We have a few more slots available. In particular we are looking for C++ gurus based in Europe. Feel free to also contact Olve Maudal directly if you are interested.

If you are curious about the NDC conference please take a look at the humorous promo video for last years event.

Sometimes you get things wrong—Marshall Clow

What is the best thing to return?

Sometimes you get things wrong

by Marshall Clow

From the article:

A few years ago, Sean Parent challenged me to provide an implementation of Boyer-Moore searching in C++. I did that, first in boost and then, later as part of the proposed Library Fundamentals Technical Specification.

The idea here is that you have a searcher object, which encapsulates the actual searching. You construct it with the pattern that you want to search for, and then you call the searchers operator() with the corpus that you want to search, and it will return to you the start of the pattern in the corpus, if it exists, and the end of the corpus, if it does not (this is the same set of rules that std::search follows).

But this weekend I realized that this is not the right thing to return. The searcher (and std::search for that matter) should return a “range” (ok, a pair of iterators) denoting the beginning and end of the pattern in the corpus. (Yes, you can get the end of the pattern by incrementing the returned iterator by the length of the pattern, but that’s an O(N) operation if you only have forward iterators...

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.