Visual C++ 2015 – Resumable Functions

Visual C++ 2015 includes a general purpose solution to implement resumable functions based on the concept of coroutines. A coroutine is a generalized routine entity which supports operations like suspend and resume in addition to the traditional invoke and return operations.
These resumable functions are being proposed for inclusion in ISO C++17.
For the VC++ 2015 Preview, the feature only works for 64-bit targets, and requires adding the /await switch to your compiler command-line.
Such resumable functions have several use cases:

  • Asynchronous operations
  • Generator pattern
  • Reactive Streams

Here is a simple example demonstrating an asynchronous operation:

#include <future>
#include <thread>
#include <experimental\resumable>

using namespace std; 
using namespace std::chrono; 
// this could be some long running computation or I/O
future<int> calculate_the_answer() 
    return async([] { 
        this_thread::sleep_for(1s); return 42; 
// Here is a resumable function
future<void> coro() { 
    printf("Started waiting... \n"); 
    auto result = __await calculate_the_answer(); 
    printf("got %d. \n", result); 
int _tmain(int argc, _TCHAR* argv[]) 

The important line here is line 17. The function calculate_the_answer() is an asynchronous function which immediately returns by returning a future. Thanks to the __await keyword on line 17, the rest of the coro() function can be implemented as if you are simply programming synchronously! No need anymore to mess around with task continuations or what not. This makes asynchronous programming much easier 😀

Read the full explanation here.


Visual Studio 2015 Preview

Microsoft has released a preview of Visual Studio 2015.
There are a lot of C++ changes included in this preview. You can read the full release notes here.

Here is a short version quoted from a blog post from Eric Battalio from Microsoft:

  • C++ Cross-Platform Mobile Development. C++ is attractive because it offers portability and a chance to reuse the same code on different platforms. With Visual Studio 2015 Preview, modern application developers can use the Visual C++ tool chain (c1xx, c2) to target Microsoft Windows Platforms and Clang / LLVM for targeting Android (with plans to support iOS in the near future). This makes it even easier to re-use existing C++ libraries to target multiple platforms (Android/Windows/iOS), share cross-platform code, and create high-quality Xamarin Native Android and Native-Activity applications using all of the power of Visual Studio. For a closer look, see Cross-Platform Mobile Development with Visual C++.
  • C++11, C++14, C++17 (proposed) compatibility. Standards support across compilers improves portability. With Visual Studio 2015 Preview, Visual C++ is even more compliant with user-defined literals (C++11), generic lambdas (C++14), and await (C++17 proposed). For a view of VS conformance in table form, see this post by Stephan Lavavej (STL). Also check out Details About Some of the New C++ Language Features, Improvements to Warnings in the C++ Compiler, and Resumable Functions in C++.
  • Enhanced productivity & build-time improvements. “Productivity” and “C++” are not often used in the same sentence except to criticize some aspect of the IDE, build process or diagnostics. Friction in any of these areas slows down the development process. With Visual Studio 2015 Preview, you get improvements in each including refactoring for C++ and improved IntelliSense database buildup and simplified QuickInfo for template deduction (IDE); incremental linking for static libs, new fast PDB generation techniques, multithreading in the linker (build); and dedicated space for analyzing graphics space using the Visual Studio Graphics Analyzer (VSGA) and you can view the impact of shader code changes without re-running the app (diagnostics). For more details about incremental build, see Speeding up the Incremental Build Scenario.
  • Improved performance. Most of the C++ developers we spoke with needed code to run fast, often as part of intensive data transformation or analysis or real-time control. Visual Studio 2015 Preview builds on the AVX2 support in Visual Studio 2013 to bring more general optimizations like loop-if unswitching, Vectorization of control flow, and increased support for Vectorization (including when optimizing in favor of smaller code). In addition we have a number of ARM32 compiler code generation improvements.

See Eric’s blog post here for a couple more links.
Download the Visual Studio 2015 Preview.


Visual Studio Community 2013

Microsoft announced the availability of Visual Studio Community 2013.
This Community edition replaces the Express editions.
You no longer have to decide which Express edition to use because the Community edition supports all kinds of development, web, mobile, desktop, …
Visual Studio Community 2013 includes all the functionality of Visual Studio Professional 2013.
Unlike the Express editions, the Community edition supports extensions.

Of course there are some restrictions on who can use this edition, but not many:

Here’s how individual developers can use Visual Studio Community:

  • Any individual developer can use Visual Studio Community to create their own free or paid apps.

Here’s how Visual Studio Community can be used in organizations:

  • An unlimited number of users within an organization can use Visual Studio Community for the following scenarios: in a classroom learning environment, for academic research, or for contributing to open source projects.
  • For all other usage scenarios: In non-enterprise organizations, up to 5 users can use Visual Studio Community. In enterprise organizations (meaning those with >250 PCs or > $1MM in annual revenue), no use is permitted beyond the open source, academic research, and classroom learning environment scenarios described above.

Download and get more information from here.


CppCon 2015 Announced

After the great success of CppCon 2014, CppCon 2015 has already been announced.
It will be held September 20-25 2015 in Bellevue, Washington, USA.
I highly recommend attending this conference if you are a C++ developer, so mark your calendars 🙂


CppCon 2014 Slides of Sessions

CppCon 2014 was a great success. There were over 100 sessions spanning 5 fully packed days.
All sessions were professionally recorded and will be available online in a month or so.
However, the slides and other material such as source code is already becoming available for download. Not everything is there yet. In the coming days, more material will become available as soon as the organizers receive the documents from the different speakers.
Download them here.


CppCon 2014

Two pictures of me at CppCon 2014.


Slides of my CppCon 2014 Presentation “Introduction to Microsoft C++ AMP”

On Monday September 8th, 2014 I gave a presentation titled “Introduction to Microsoft C++ AMP” at CppCon 2014.
The slides of my presentation can be downloaded below:

This was the first edition of CppCon and it was a great success.
Looking forward to next year’s edition 🙂


CppCon 2014 Presentation

CppCon is the annual, week-long face-to-face gathering for the entire C++ community. The conference is organized by the C++ community for the community. Taking place this year in the beautiful Seattle neighborhood and including multiple diverse tracks, the conference will appeal to anyone from C++ novices to experts.

What you can expect at CppCon:

  • Invited talks and panels: the CppCon keynote by Bjarne Stroustrup will start off a week full of insight from some of the world’s leading experts in C++. Still have questions? Ask them at one of CppCon’s panels featuring those at the cutting edge of the language.
  • Presentations by the C++ community: What do embedded systems, game development, high frequency trading, and particle accelerators have in common? C++, of course! Expect talks from a broad range of domains focused on practical C++ techniques, libraries, and tools.
  • Lightning talks: Get informed at a fast pace during special sessions of short, less formal talks. Never presented at a conference before? This is your chance to share your thoughts on a C++-related topic in an informal setting.
  • Evening events and “unconference” time: Relax, socialize, or start an impromptu coding session.

I’ll be giving a presentation myself at CppCon 2014: Introduction to C++ AMP (GPGPU Computing).

If you use C++, you should seriously consider coming to the conference.


C++14 STL Features, Fixes, And Breaking Changes In Visual Studio 14 CTP1

Stephan T. Lavavej, aka STL, has written a very detailed blog post describing new C++14 STL features, implemented fixes, and breaking changes in Visual Studio 14 CTP1. Read it here.

One notable breaking change is that containers cannot have const elements:

The Standard has always forbidden containers of const elements (e.g. vector, set). (C++98/03’s prohibition was crystal clear: elements must be Assignable, which const T isn’t. C++11/14’s prohibition is obscurely hidden, but it’s there.) Previously, VC accepted such containers due to non-Standard machinery in std::allocator. We’ve removed that machinery, so such containers now fail to compile.


Visual Studio “14” CTP

Microsoft has released Visual Studio “14” CTP. You can read the announcement on Soma’s blog. Visual Studio “14” will most likely be available sometime in 2015.

Note: This is a CTP release, thus it should be installed in a test environment, such as a VM or a clean machine. Do not install on a machine with another version of Visual Studio installed.

Specifically for C++, there are quite a few improvements, such as:

  • Generalized lambda capture
  • User-defined literals in the language and standard library
  • Completed noexcept
  • Inline namespaces
  • Thread-safe “magic” statics
  • Unrestricted unions
  • All November 2013 compiler CTP features
  • Null forward iterators
  • quoted()
  • Heterogeneous associative lookup
  • integer_sequence
  • exchange()
  • get()
  • Dual-range equal(), is_permutation(), mismatch()
  • tuple_element_t
  • Filesystem “V3” Technical Specification (TS)
  • Object file size reductions
  • Debug checking fixes
  • Create declaration or definition
  • Native memory diagnostics
  • Refactored C Runtime (CRT): This CTP contains the first preview of the substantially refactored CRT. msvcr140.dll no longer exists. It is replaced by a trio of DLLs: vcruntime140.dll, appcrt140.dll, and desktopcrt140.dll.

Read Eric’s blog for a bit more details on those improvements.

Download the CTP.


2048 Pro

2048 Pro IconNuonSoft has released 2048 Pro for Windows 8 and Windows 8.1.

2048 Pro is the most addictive game since Flappy Bird made easy! It is a fun and challenging puzzle to slide tiles and match them together.

Vote for us here
2048 Pro was created by Marc Gregoire and Peter Van Weert. We are participating in a contest organized by Microsoft. We would really appreciate it if you could vote for us.

Playing 2048 Pro earns you credits, credits buy you “lifelines”. Made a mistake? Undo! Stuck? Ask for hints, and watch the computer clean up your mess!


  • Swipe to move all numbers left, right, up, or down.
  • If two identical numbers collide, they merge into one. For example: 2+2=4, 16+16=32, …
  • The goal is to reach the magic 2048 tile (or higher of course!)

Coming soon

  • Regular updates with fixes and new features
  • More game modes
  • Global leader board
  • Strategy guide: learn how to play

Get 2048 Pro now from the Windows Store and give it a rating or visit the 2048 Pro website.


Microsoft MVP VC++ 2014 Award

Today I got a mail from Microsoft saying that my MVP (Most Valuable Professional) award for Visual C++ is extended for 2014 🙂

Congratulations! We are pleased to present you with the 2014 Microsoft® MVP Award! This award is given to exceptional technical community leaders who actively share their high quality, real world expertise with others. We appreciate your outstanding contributions in Visual C++ technical communities during the past year.

See my MVP profile.


Next BeCPP UG Meeting Planned For May 8th, 2014

The next meeting of the Belgian C++ Users Group is planned for Thursday May 8th, 2014 at 18:00 at Materialise HQ.

Materialise ( ) is sponsoring this event by providing the location, drinks and catering

We will have an international speaker for this event: Artur Laksberg.

  • Artur Laksberg leads the Visual C++ Libraries development team at Microsoft, responsible for the STL, CRT, C++ AMP, PPL, Casablanca and other libraries. His interests include concurrency, programming language and library design, and modern C++. Artur is one of the co-authors of the ISO C++ proposal on Parallelism (aka Parallel STL) as well as the Concurrency Technical Specification.

If you ever wanted to ask a question to a member of the Visual C++ product team, now is your chance.

The agenda is as follows:

  • 18:00: Sandwiches.
  • 18:30: Session 1: Parallelism in the Standard C++: What to Expect in C++ 17 (Artur Laksberg)
    It is 2014 and parallel programming has entered the mainstream. No longer is it the domain of the few highly trained experts. The tools available in the C++ today make parallelism accessible – if not yet easy – to average developers. However, writing efficient cross-platform parallel code in C++ is still hard. The standard constructs available in C++ 11/14 are too basic and too low-level. More advanced tools exist, but most are either vendor-specific or don’t work on all platforms. In this presentation, we’ll talk about the joint effort spearheaded by several members of the ISO C++ Committee to bring parallelism into the C++ Standard Template Library. The project known as the “Parallel STL” aims to bring muliticore and SIMD parallelism into the next revision of the ISO C++ Standard.
  • 19:30: Break
  • 19:45: Session 2: Asynchronous programming with futures and await (Artur Laksberg)
    We have to write asynchronous code for a number of reasons, such as making our GUI apps more responsive, or our server code more scalable. Dealing with asynchrony is hard, perhaps harder than parallelism, and doing it in C++ in a portable way is even harder. If you are familiar with the “callback soup”, “control flow inversion” and other such phenomena, you’ve experienced the pain of asynchrony. In this presentation, we’ll look at the state of the art of asynchrony in C++, discuss futures and continuations, await and resumable functions, and how these concepts are making their way to Standard C++.
  • 20:45: Guided tour of the Materialise facilities for interested people followed by a drink.

The event is free for everyone, but you need to register for it.

There are 100 seats available for this event.

Read the official announcement.

Register for this free event.


My BeCPP Presentation “What’s new in Visual C++ 2013”

On Monday March 17th, 2014 I gave a “What’s new in Visual C++ 2013” presentation for the Belgian C++ Users Group (BeC++).
This time there were around 55 attendees for the BeC++ meeting, quite a success 🙂
The slides of my presentation can be downloaded below:

Peter Van Weert gave a presentation “What’s new in C++14”.
His slides can be downloaded from the official BeC++ blog.

There are also a couple of pictures from the event on the BeC++ blog.

And I already started planning the next Belgian C++ Users Group meeting. It will be on May 8th, 2014. Details will follow soon.


C++ AMP Presentation for KLA Tencor / ICOS

Today I gave an introduction presentation on C++ AMP for software engineers and team leads of KLA Tencor / ICOS. The presentation was almost the same as I gave on Meeting C++ in November 2013.
The slides can be downloaded below:


Introduction to WIC: How to use WIC to load an image, and draw it with tranparency using only GDI?

A while ago I wrote an article: “Introduction to WIC: How to use WIC to load an image, and draw it with GDI?”

The code in that article didn’t handle transparency.
It’s actually trivial to implement transparency in that sample code. Read the rest of this entry »


Next BeCPP UG Meeting Planned For March 17th, 2014

The next meeting of the Belgian C++ Users Group is planned for Monday March 17th, 2014 at 18:00 at KLA-Tencor / ICOS Belgium.

KLA-Tencor / ICOS Belgium ( ) is sponsoring this event by providing the location, drinks and catering.

KLA-Tencor/ ICOS Belgium

The agenda is as follows:

  • 18:00: Sandwiches.
  • 18:30: Session 1: What’s new in C++14 (Peter Van Weert)
    An overview of the new features in the latest C++14 standard.
  • 19:30: Break
  • 19:45: Session 2: What’s new in Visual C++ 2013 (Marc Gregoire)
    An overview of the new features in Visual C++ 2013 and the Visual C++ 2013 November CTP.
  • 20:45: Short technically oriented presentation by the host KLA-Tencor / ICOS Belgium.
  • 21:00: Drink.

Read the official announcement.

Register for this free event.


C++11 – Contextually Converted to bool

In C++, a one-argument constructor can implicitly be used to convert some source value or object into an instance of your class.
To prevent this you can mark your one-argument constructors as explicit. In that case, if you want the conversion you have to explicitly perform the casting.
C++11 adds this functionality to conversion operators as well, however, its behavior surprised me.
For example:

#include <iostream>

using namespace std;

class Foo
	explicit operator bool() const { return true; }

int main()
	Foo f;
	if (f)
		cout << "f is true" << endl;
	return 0;

The output of this piece of code is “f is true”.
In other words, the compiler is implicitly converting f into a Boolean, even though the conversion operator is marked as explicit.
This surprised me. I immediately blamed it on a compiler bug. However, after some more investigation, it turns out the C++ standard has this notion of “contextually converted to bool”.
The C++ standard has a paragraph explaining this behavior, section 4 Standard conversions [conv]

3 An expression e can be implicitly converted to a type T if and only if the declaration T t=e; is well-formed, for some invented temporary variable t (8.5).
4 Certain language constructs require that an expression be converted to a Boolean value. An expression e appearing in such a context is said to be contextually converted to bool and is well-formed if and only if the declaration bool t(e); is well-formed, for some invented temporary variable t (8.5).

Searching through the standard, an expression can be contextually converted to bool in several cases, not only in the above if-statement.
I also found this blog post explaining this behavior.


Beluga – Pictures

A couple of weeks ago I had a very nice 10 course dinner in the Beluga in Maastricht.

All 10 dishes were amazing, paired with a very nice selection of wines 🙂 Here are some pictures:

Read the rest of this entry »


Visual Studio 2013 Update 1

Visual Studio 2013 Update 1 has been released.

The following are Visual C++ related bug fixes:

  • Assume that you edit a dialog that contains at least one picture control in Resource Editor. After you save the file, the project can no longer be compiled.
  • When you edit multiple resources in Resource Editor, Visual Studio crashes randomly.
  • Addresses some Visual C++ automatic formatting issues.
  • Visual C++ IDE does not work as expected if there is an unexpected registry subkey under the following registry key:
  • When you try to link with PGO on amd64_x86 complier, Visual Studio crashes.

Update 1 is a rather small update. A list of all the fixes can be found here.

Download the update from here.

S. Somasegar said that they are well underway on Visual Studio 2013 Update 2, their first major feature update for VS2013, which they are looking forward to delivering this spring.