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 ( http://materialise.be/ ) 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 ( http://kla-tencor.com/ ) 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.


Modern C++ Tips and Tools

C++ allows you to write clean, safe and fast code, and writing it is even easier than ever thanks to new features in C++11 and C++14. This article highlights a couple of tips.

Comments & ‘Cleverness’

Code gets read a lot more often than it gets written, so make sure that your code can be read and understood in the future, by yourself and by other developers. This means that you have to add comments, and that you should avoid trying to make code as terse and ‘clever’ as possible; because that hurts readability.

Memory Management

In modern C++ you should avoid any explicit calls to delete operators or functions to deallocate memory such as free(). Code that relies on such explicit calls is susceptible to memory leaks. For example:

void foo(size_t size) {
    char* buffer = new char[size];
    // ...
    delete [] buffer;

The code is straightforward; it allocates memory, does something with the memory, and then deletes the memory. It uses a ‘naked’ pointer, which you have to manage yourself. This piece of code causes a memory leak if an exception is thrown before the delete operator is called. You should avoid using naked pointers, instead use encapsulation objects that automatically handle the memory. For example, the above code should be written using a container such as a vector:

void foo(size_t size) {
    std::vector buffer(size);
    // ...

Using a container, there is no need to free the memory, the destructor of the container will handle all that for you. Similarly, if you need dynamically allocated objects, do not store them in naked pointers, instead use smart pointers such as std::unique_ptr, which is not reference counted, or if you need shared ownership, std::shared_ptr, which is reference counted. unique_ptr will automatically delete the object when the unique_ptr goes out of scope. An object wrapped in a shared_ptr is automatically deleted when the reference count goes to zero.

When you use unique_ptr, use std::make_unique<>(). Similarly, use std::make_shared<>() when you use shared_ptr.

One key point to remember: never use std::auto_ptr, it has officially been deprecated because of its problems. One of its problems is that it is forbidden to store them in STL containers because auto_ptr does not meet C++98/03’s requirements for container elements.  unique_ptr  and shared_ptr don’t have any of these problems and are perfectly safe to use in STL containers.

The auto Keyword

Use auto to let the compiler deduce the type of variables automatically. This helps a lot with complicated types that are hard or even impossible to write. For example:

std::map<std::string, std::vector> myMap;
for (std::map<std::string, std::vector>::iterator iter = begin(myMap);
     iter != end(myMap); ++iter)

This is complicated, difficult to write and error prone.
Note that since C++11 it’s recommended to use the non-member functions std::begin(), end(), cbegin(), cend(), rbegin(), rend(), crbegin(), and crend() instead of the member functions.
Using the auto keyword the above can be rewritten in a very clean way:

for (auto iter = begin(myMap); iter != end(myMap); ++iter) { ... }

Using the range-based for loop, the code can be written even more elegantly:

for (auto&& item : myMap) { ... }


for (auto& item : myMap) { ... }


for (const auto& item : myMap) { ... }

Never write the following, unless your container only contains primitive types:

for (auto item : myMap) { ... }

If you use this for containers with non-primitive elements performance will suffer because item will be a copy of each of the elements in the container.


Do not use NULL for pointers, use the nullptr keyword. NULL is a macro for 0 which can sometimes result in problems that are hard to track down. nullptr is really a null pointer type and is not just a macro for 0.

Move Semantics

Move semantics since C++11 helps with performance, allowing objects to be moved instead of copied. It is based on rvalue references, represented as &&. C++ automatically uses move semantics in cases where the source object will cease to exist. You can explicitly move an object by using std::move(). The STL also supports move semantics. To add move semantics to your classes you only need to implement a move constructor and move assignment operator which have the following prototype:

MyObject(MyObject&& src);               // Move constructor
MyObject& operator=(MyObject&& rhs);    // Move assignment operator

Lambda Expressions

Lambda expressions are a powerful addition to the C++ language. One huge benefit is that they make it much easier to use STL algorithms. For example, you can use the count_if() algorithm in combination with a simple lambda expression to count all elements in a vector that are less than 0.

std::vector vec;
auto count = std::count_if(cbegin(vec), cend(vec),
    [](int i){ return i < 0; });

Investing time in learning about lambda expressions will pay itself off quickly.


You should read up on the threading functionalities introduced in C++11. One useful and often overlooked function is std::call_once(), used to make sure that a specific callable entity is executed exactly one time, no matter how many threads call it simultaneously. This can for example be used to make a compact and thread safe implementation of the singleton pattern.


Text matching, parsing, and searching can be tricky and complicated, especially when it should work with Unicode strings. You should avoid writing your own functions to perform such operations, instead use classes from <regex> such as std::wregex.

C++11 supports raw string literals. They are extremely useful in the context of regular expressions. For example, the following regular expression searches for spaces, newlines, and backslashes:

string s = "( |\\n|\\\\)";

The last 4 backslashes are correct. If you want to match a backslash, it needs to be escaped in the regular expression, thus \\. If you want to write \\ in a normal string literal, you need to escape both backslashes, resulting in 4 of them. Using raw string literals you simply write:

string s = R"(( |\n|\\))";

R”( and )” denote the boundary of the raw string literal.

Random Numbers

If your application needs to generate random numbers, don’t use the old C style srand()/rand() functions. Their randomness is not good. Instead, use <random>, which contains classes to generate random numbers, such as a Mersenne Twister, and supports different mathematical distributions, for example a uniform distribution, a Poisson distribution, and so on.

Further Reading

Take a look at “Professional C++ 2nd Edition” if you are determined to master C++, including all C++11 features.


Happy New Year 2014

Happy New Year
Sretna Nova Godina
Gelukkig Nieuwjaar
Bonne Année


MVP Global Summit 2013 November Report

I gave a report of the November MVP Global Summit 2013 to software engineers in my company. Obviously, I’m only talking about things that did not fall under NDA.
The slides can be downloaded below: