April 2015

Template Code Bloat Revisited—Jason Turner

Jason Turner discusses in his recent article the size of instantiated template code.

Template Code Bloat Revisited Smaller Makeshared

by Jason Turner

From the article:

Back in 2008 I wrote an article on template code bloat. In that article I concluded that the use of templates does not necessarily cause your binary code to bloat and may actually result in smaller code!

However, after spending the last few months optimizing and evaluating ChaiScript I've learned that the misuse of templates, particularly when inheritance is involved, can have a huge impact on code size.

Serializing access to Streams—Marco Foco

A new blog post containing runnable code from the Italian C++ Community:

Serializing access to Streams

by Marco Foco

From the article:

Two or more threads were writing to cout using the form:

cout << someData << "some string" << someObject << endl;

And one of the problems was that data sent from one thread often interrupted another thread, so the output was always messed up. [...] I started designing a solution by giving myself some guidelines, here listed in order of importance...

N4487: Constexpr Lambda—Faisal Vali, Ville Voutilainen, Gabriel Dos Reis

New WG21 papers are available. If you are not a committee member, please use the comments section below or the std-proposals forum for public discussion.

Document number: N4487

Date: 2015-04-28

Constexpr Lambda

by Faisal Vali, Ville Voutilainen, Gabriel Dos Reis

Excerpt:

This proposal suggests allowing lambda-expressions in constant expressions, removing an existing restriction. The authors propose that certain lambda-expressions and operations on certain closure objects be allowed to appear within constant expressions. In doing so, we also propose that a closure type be considered a literal type if the type of each of its data-members is a literal type; and, that if the constexpr specifier is omitted within the lambda-declarator, that the generated function call operator be constexpr if it would satisfy the requirements of a constexpr function (similar to the constexpr inference that already occurs for implicitly defined constructors and the assignment operator functions).

Thoughts About C++17—Bjarne Stroustrup

We normally wait until committee papers get "N" (permanent) numbers, but this one is an exception. It has also already been circulated to ISO C++ committee members in preparation for the next ISO C++ meeting that begins on Monday in Lenexa, Kansas, USA.

D4492: Thoughts About C++17

by Bjarne Stroustrup

From the paper:

This is a draft intended to focus a discussion at the Lexena committee meeting.

This is an extended version (based on feedback) of an internal committee standard reflector message that got so widely distributed and discussed that it would be a good idea to have it as a document. I have tried to remove distracting committee jargon. Thanks to people who took part in the reflector discussion or commented on the web. I have also added links. It is still a collection of thoughts aimed at stimulating a discussion, rather than a formal paper or a precise proposal.

The note was written for committee members, but “escaped into the wild.” Here are a few comments from the web: [Reddit] [The Register] [Hacker News]

As you see, people outside the committee also have strong opinions. Those opinions can depart radically from the ones I hear in the committee and from reality.

I am often asked “what will C++17 be?” and variations of “What will C++17 do for me?” ... [continue reading]

CppCon 2014 Another fundamental shift in Parallelism Paradigm?—Michael Wong

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

Another fundamental shift in Parallelism Paradigm?

by Michael Wong

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Another fundamental shift in Parallelism Paradigm? Sure. When was the last time you heard that before?

But seriously, as the number of threads/cores continue to increase, there is a growing pressure on applications to exploit more of the available parallelism in their codes, including coarse-, medium-, and fine-grain parallelism. OpenMP has been one of the dominant shared-memory programming models but is evolving beyond that with a new Mission Statement (no, really!) making it well suited for exploiting medium- and fine-grained parallelism.

OpenMP 4.0 exhibits many of these features to support the next step in both consumer, high-performance and exascale computing, with one of the world's first programming model for high-level language support for GPU/Accelerators and vector SIMD across not 1 but 3 high-level languages: C++, C, and that language whose name we dare not speak, but starts with F.

Announcing Cat: a C++14 Functional Library—Nicola Bonelli

Cat is meowingA new open source C++14 Functional Library has been released:

Cat: a C++14 Functional Library

by Nicola Bonelli

From the article:

Cat is a C++14 library, inspired by Haskell. Cat aims at pushing the functional programming approach in C++ to another level. [...] On one hand it works for filling the gap in the language with respect to functional programming. [...] On the other hand Cat promotes the use of generic programming with type classes, inspired by Category Theory.

N4402: Resumable Functions (revision 4)—Gor Nishanov, Jim Radigan

New WG21 papers are available. If you are not a committee member, please use the comments section below or the std-proposals forum for public discussion.

Document number: N4402

Date: 2015-03-31

Resumable Functions (revision 4)

by Gor Nishanov, Jim Radigan

Excerpt:

Revisions and History

This document supersedes N4286. Changes relative to N4286 include:

  • renaming customization points back to resumable_traits and resumable_handle as they were in N4134;
  • changing requirements on the return type of initial_suspend() and final_suspend() to be lexically convertible to bool;
  • changing requirements on the return type of yield_value() to be either of a void type or a type lexically convertible to bool;
  • making a set_result member function optional in a promise type; the absence of a set_result indicates that resumable function does not support an eventual return value and using await operator or for-await statement is not allowed in resumable functions with such promise;
  • altered cancellation mechanism in resumable functions; instead of using cancellation_requested() member function in a promise to indicate that on the next resume resumable function need to be cancelled, an explicit member function destroy() is added to the resumable_handle. A destroy() member function can be invoked to force resumption of coroutine to go on the cancel path;
  • added resume(), destroy(), and done() member functions to resumable_handle;
  • moved proposed wording into a separate document N4302;
  • removed trivial awaitables suspend_always, suspend_never and suspend_if; switching yield_value, initial_suspend, and final_suspend to return bool eliminated the need for those;

Terms and Definitions

Coroutine

A generalized routine that in addition to traditional subroutine operations such as invoke and return supports suspend and resume operations.

...