Microsoft recently announced that it released version 15.5 of Visual Studio 2017 (and Visual Studio for Mac version 7.3).

There are various improvements to performance and diagnostics (such as cutting the solution load times for large C# and VB projects by half), new features for C#, C++, F# development, and others. You can read the announcement and the release notes to get the complete list. Concerning VC++, the claim is that it now supports 75% of the C++17 features, although I’d still like to see an update on the supported feature list.

The VC++ compiler supports 75% of the C++ 17 features. In addition, the team has added new optimizations to the compile.

However, looking back at the previous releases I just realized how many have been. I put them all in a table (as far as I figured this should be the complete list). The total is 11 releases within the past 9 months.

Release Update Date Link
15.5 .0 2017-12-04 Release notes
15.4 .5 2017-11-27 Release notes
.4 2017-11-14 Release notes
.3 2017-11-08 Release notes
.2 2017-10-31 Release notes
.1 2017-10-19 Release notes
.0 2017-10-09 Release notes
15.3 2017-08-14 Release notes
15.2 2017-05-10 Release notes
15.1 2017-04-05 Release notes
15.0 2017-03-31 Release notes

That reminds me of this good old quote from the Gladiator movie:

Tell me, what have you been doing, busy little bee?

Tell me, what have you been doing, busy little bee?


The Visual Studio teams have been some busy little bees. Kudos!

, , , Hits for this post: 591 .

It’s said that a picture is worth a thousand words. An animated GIF is probably worth even more. I have always wanted to show my reaction to code with pictures. Being able to display images along source code could have a lot of benefits beyond that. By inserting images within code we could better explain snippets, visualize algorithms, or other things. Luckily Visual Studio allows us to customize the WPF editor with extensions that actually enable us to do so. Therefore I have created an editor extension for Visual Studio that enables displaying images, including animated GIFs, within the source code. It’s called Memeful Comments and is available for free in the Visual Studio marketplace.

Download the extension from Visual Studio Marketplace.

The source code is publically available on GitHub.

Here is how it works: original source code like this JavaScript snippet

is displayed as shown here when the extension is enabled:

The following languages are supported:

  • C#
  • C and C++
  • F#
  • VB.NET
  • JavaScript and TypeScript

Here is a longer video showing how this works while editing text.

To display images, including animated ones, in your source code in any of the supported languages, you have to add an <image> tag. The following attributes are supported:

Attribute Required Description
url or src Yes Represents the source of the image. It can be either from a local disk or from the web. If the file is from the local disk it can be either absolute or relative to the document path.
scale No Indicates a scaling factor for the image. Notice that a very large scale might make the image impossible to display.

Here are examples in various programming languages:

  • C#
  • C++

  • VB.NET

  • F#

  • JavaScript/TypeScript

Enjoy the extension and send me feedback!

Credits
This extension is based on the image-comments extensions by Luke McQuade.
, , , , , , Hits for this post: 1369 .

Four years ago I wrote a blog post that shown how to build a web server using the http_listener from the C++ REST SDK library as well as a client application that consumed the exposed resources. Over the years there have been various changes to the API from the library and some readers complained the code no longer compiled. Eventually, I decided to revisit that post and update my code to the latest version of the library, which at this time is 2.10.

I will not reiterate all the details described in the former article. However, in summary, the server maintains a dictionary of values (both keys and values are strings). Through HTTP calls a client can retrieve the content of the dictionary, add new values, update or delete existing ones.

HTTP method Description Request Response
GET retrieves all the key-value pair from the dictionary {"one" : "100", "two" : "200"}
POST retrieves the values of the specified keys from the dictionary ["one", "two", "three"] {"one" : "100", "three" : "", "two" : "200"}
PUT inserts new pairs of key-values in the dictionary; if a key is already found its value is updated {"one" : "100", "two" : "200"} {"one" : "", "two" : ""}
DELETE deletes the specified keys from the dictionary ["one"] {"one" : ""}

Here is the server code:

And this is the client code:

Notice there are slight changes in the way output is formatted, both in the server and the client application. The rest is mostly unchanged, except for the handling of JSON, that has changed significatly since version 1.1. Again, please see the original post for an explanation of the code.

The output from running these client and server applications is shown below. On the left is the client output, and on the right the server output.

, , , Hits for this post: 1243 .

But why?

Today I wanted to rework an example that I wrote years ago. I was a client-server example using the C++ REST SDK. I haven’t worked with the library for a while, so I needed to install the latest version first.

If you go to the C++ REST SDK project page it says you need to run the following command to install it:

For that, you need the vckpg package management system for C and C++ libraries on Windows. Getting and installing it is not that hard: you have to either clone the git repo or download and unzip it locally. Then you need to run two commands:

So I did all that and then installed the C++ REST SDK. It took about one hour and 11GB (!!) of disk storage for this. It had to download, build and install the following libraries:

  • boost:x86-windows
  • boost:x64-windows
  • bzip2:x86-windows
  • bzip2:x64-windows
  • cpprestsdk:x86-windows
  • cpprestsdk:x64-windows
  • openssl:x86-windows
  • openssl:x64-windows
  • websocketpp:x86-windows
  • websocketpp:x64-windows
  • zlib:x86-windows
  • zlib:x64-windows

This is utterly insane. All that I want is some headers and a few static and dynamic libraries. But instead I got 11GB of God knows what and waited about one hour before I could start to work.

Why is all this necessary? Why do I have to care about all this provisioning process? We don’t care about your time and resources, we’re cool we can do this with scripts? Seriously? What happened to the good old fashion of downloading an archive with everything you needed already built for you? Now you first need to install 400MB of Perl to be able to build and get going with a C++ library. It’s sad.

, , Hits for this post: 1110 .

In the previous post, I have shown how you could write a simple Twitter bot using JavaScript and Node.js very quickly. However, I ran the bot on my local machine, which is probably not something that you want to do for a real application. Instead, you’d probably want to host it on a cloud platform. In this article, I will show how you can do that also in no time using Heroku. Heroku is a cloud platform for building and running applications that takes away the complexity of setting up an entire infrastructure. This makes it well suited for simple things like the bot we previously created.

A word on Azure

Since I have an Azure account and MSDN subscription my first choice for hosting the bot was Azure. However, I learned something important.

After wasting too much time looking into both web apps and Azure Cloud Services, installing Azure Power Shell, learning to use it, setting up worker roles, deploying, etc. and still not getting the bot to work (unless accessed through a URL) I decided to move on and find something that even someone unfamiliar with can quickly grasp in minutes.

Starting with Heroku

Heroku is a platform that you can use for free for experimenting if you don’t require too many resources. Of course, there are paid plans, depending on your needs. However, for the simple bot I was building there would be no incurring costs.

Pricing is based on dyno hours. Dynos are lightweight Linux containers in which an application runs. A dyno can belong to one of the three possible configurations: web (that receive HTTP traffic from routers), worker (typically background jobs, queueing systems, and timed jobs), and one-off (temporary dynos that can run detached, or with their input/output attached to your local terminal, typically used for administrative tasks, such as database migrations and console sessions). You can get up to 1000 dyno hours per month for free, which is enough to run an application with no costs. Should you need to host more, then you’d have to pay for it.

After creating the account, you should download and install the Heroku CLI (previously known as Heroku Toolbelt). This allows you to create and manage Heroku apps from the command line on Window, MacOS and Debian/Ubuntu.

Creating a Heroku app

After creating an account and signing in you can create applications from the dashboard. You must specify a unique name and a data center where it should be hosted.

Heroku has its own git to store your project sources. You can find instructions under the Deploy page for how to create the project locally and commit it to Heroku’s git repository.

Defining a Procfile

Apart from the bot source files that we created in the previous article (package.json, bot.js, and others that might be necessary), we need to declare a Procfile in the root directory of the app. This is a text file that defines what command should be executed to start the application. The content of this file should be the following (assuming that the entry point of the bot is called bot.js).

This is necessary because the Twitter bot is not a web app, but a worker app that runs on the server and does something periodically in the background, not based on HTTP requests.

After uploading the source files including the Procfile to the heroku git repository, go to the application and under the Resources tab, stop the web dyno and start the worker dyno.

Note: a web dyno is created by default for every application.

And that’s it, the Node app now runs successfuly on the platform in the background.

See more

Deploying Node.js Apps on Heroku
Getting Started on Heroku with Node.js
Dynos and the Dyno Manager

, , , , , , , Hits for this post: 1895 .

I had recently played with the idea of creating a twitter bot, not for any specific reason but to see how hard or easy that would be. And to do something that would put a bit of fun into the experience I decided to make a bot that would create nice tweets with emoji of bugs. Here is an example:

It turned out that creating such a bot is a no time consumer when done in JavaScript with Node. The result of my experiment is available here: https://twitter.com/emojibugs.

This article explains the necessary steps to build a simple Twitter bot that posts messages periodically, at some pre-defined interval.

Twitter account and app

The first thing to start with is a Twitter account. This could be either an existing account or a new one.

After setting up the account the bot should be tweeting on behalf of you need to go and create an application. That can be done from https://apps.twitter.com/. You need to create a new app, provide a name, description, website and other optional ones.

After the app is created you need to go to Keys and Access Tokens and generate them for the application. These will be used later on to sign it to Twitter from the bot, and specifically:

  • Consumer key (API key)
  • Consumer secret (API secret)
  • Access token
  • Access token secret

NOTE: should these keys and secrets be compromised new ones can be generated (which invalidates the previous ones).

Creating a bot in JavaScript

A very simple solution for a simple bot like this is creating a Node package in JavaScript. Node.js is a JavaScript runtime built on Chrome’s V8 JavaScript engine that enables running JavaScript code outside the browser. Node comes with npm, which is a package manager for JavaScript.

Download and install Node.js: https://nodejs.org/en/
Learn more about npm: https://www.npmjs.com/

There is a Node package for the Twitter client API. It’s called twit and is very easy to use. The following is the only JavaSCript code you need to write to post a new tweet with the text “hello world!” on the registered account.

What you need to do here is fill in the API key and secret and the access token and secret with the ones generated for your app.

Creating a Node package

To create a new package go to an empty folder where you want to locate the package and run the npm init command in a console. This will prompt you to provide some information (some of which are already filled in for you).

There result is a file called package.json that describes the Node package and its dependencies.

To install the twit package for the Twitter client api run the following command in a console in the folder where the package is located:

The twit module and all its dependencies will be downloaded in this folder and the package.json file updated with the dependency:

Writing the bot

When we created the Node package we specified that the entry point should be a file called bot.js. We need to create this and fill it with the following code:

The function generateText creates the text to be posted in a tweet. It can do anything and for the sake of this post its content is irrelevant. Function tweetIt does a status update with a text generated by generateText. This function is executed both when the package is run the first time as well as every six hours (a timer is created with setInterval).

Running the bot locally

You can run the script locally in two ways:

  • By running the following command:
  • By adding a script to package.json and execuring that script.

    And then executing the following command:

It’s done

That is all that is necessary for a Twitter bot to run and post to a Twitter account. Of course, there are things that have been let aside, such as how to generate the content of the message, how to host the bot on a cloud platform, or how to write a bot that does more that posting text, such as posting images, replying, etc. But some of that in the next article.

, , , , , , Hits for this post: 1958 .

Computing day of year in C++

I have been recently asked on my post on the date library if the library has a function for computing the day of the year. It actually does not, although it is fairly simple to compute it.

UPDATE: Howard Hinnant has shown in a comment below how to write a day_of_year() function using the date libray.

Let’s look at the days of the year.

Day Day of year
January 1 1
January 2 2
January 31 31
February 1 32
February 28 59

Here is where things complicate a bit, because during leap years February has 29 days. So we actually need to have two counts of days.

Day Day of non-leap year Day of leap year
January 1 1 1
January 2 2 2
January 31 31 31
February 1 32 32
February 28 59 59
February 29 N/A 60
March 1 60 61
December 31 365 366

It is fairly simple to compute the day of the year based on the day of the month if we knew the day of the year of each first day of the month. That can be also put in a table.

Day of month Day of non-leap year Day of leap year
January 1 1 1
February 1 32 32
March 1 60 61
April 1 91 92
May 1 121 122
June 1 152 153
July 1 182 183
August 1 213 214
September 1 244 245
October 1 274 275
November 1 305 306
December 1 335 336

So we can compute the day of the year as:

We can simplify that a bit by subtracking 1 from the day of the year values in the table above, such that January 1st is the day 0, February 1st is day 31, etc.

The following code sample shows how this can be written in C++:

And how it can be used:

This day_of_year() function can be used with the date library too. I’ll just add one more utility function that takes a date::year_month_day value and returns the day of the year.

And we want to know what day of the year today is then we can do that too:

The day_of_year() function is very simple and does not do any argument checks. That makes it possible to compute dates such as 2017.08.55 or 2017.55.100. Obviously, these not only that do not make sense, but indexing the days_to_month array beyond its bounds is undefined behavior. That means that in practice you should write a function that validates the arguments and throws an exception upon error. However, in this case, the day_of_year() can not be constexpr anymore.

This would throw an exception on dates like 2017.13.1 or 2017.1.50, but would not do so for 2017.2.30 or 2017.11.31 that are also invalid dates. That can be further corrected by verifying that the day of the month does not exceed the number of days that month can have in the given year.

, , , Hits for this post: 4624 .

You may have multiple versions of the .NET framework installed and used on your machine. The framework has two components: the set of assemblies that provide functionalities for your application, and the common language runtime (CLR) that handles the execution of the application. These two components are versioned separately. If you what to see what versions of the framework are installed, you have to query the Windows Registry. If you want to know what versions of the CLR are installed you could either use clrver.exe or do it programmatically. In this article, we will look at this later option and how to do it in C++.

How to: Determine Which .NET Framework Versions Are Installed

To query the installed CLR versions from C++ we have to:

In order to call CLRCreateInstance we must include the metahost.h header and link with the Mscoree.lib static library.

To use the ICLRMetaHost and ICLRRuntimeInfo interfaces we must import the mscorlib.tlb type library. The _COM_SMARTPTR_TYPEDEF are used for defining COM smart pointers ICLRMetaHostPtr and ICLRRuntimeInfoPtr that automatically handle the reference counter of the underlying COM object.

The call to the EnumerateInstalledRuntimes method, when successful, returns a pointer to an IEnumUnknown interface. This enables enumerating through a component that contains multiple objects. Its method Next retrieves a specified number of items. In this implementation that number is 1. The return value is a pointer to the IUnknown interface, but what we are enumerating through are actually ICLRRuntimeInfo interfaces.

To retrieve the version info we must use the GetVersionString method of ICLRRuntimeInfo. The arguments are an array of wide characters that will receive the string and the size of the array. In order to retrieve the necessary size of the buffer, we have to first call the method with null for the first argument. In this case the function returns ERROR_INSUFFICIENT_BUFFER as a HRESULT (i.e. HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)) and sets the second argument to the necessary size. After allocating the necessary buffer, we call the method again, providing the buffer and its size.

Running this program on my machine prints the following (which is the same as the output from clrver.exe).

, , , Hits for this post: 4620 .

Firebase is a platform for developing mobile and web application that provides analytics, authentication, real-time databases, notifications, cloud messaging, crash reporting and other services for your application. In this post, I will discuss how to use the Firebase Analytics in Cordova applications for measuring app usage and user engagement.

Analytics for Firebase

This is a free service that can be used for both Android and iOS applications. It provides unlimited reporting of up to 500 distinct events and a number of user properties.

Events allow you to see what happens in an application, such as user actions, system events, or errors. There is a number of automatically collected events and you can define your own events. However, you have to keep in mind that:

  • there is a limit of 500 distinct events that can be reported.
  • each event can have up to 25 parameters associated with it.
  • event names can be up to 40 characters long, may only contain alphanumeric characters and underscores (“_”), and must start with an alphabetic character.
  • “firebase_”, “google_” and “ga_” prefixes are reserved and cannot be used.
  • names are case-sensitive and logging two events whose names differ only in case will result in two distinct events.

See FirebaseAnalytics.Event for more information.

User properties are information about the user that is recorded together with the events. Default collected user properties include user info (age, gender, country, language, interests), device info (brand, category, model) and app info (version, app store, first open time, new/established).

Appart from the implicitly collected user properties you can define your own. For that, however, you must use the Firebase console. You must be careful with the properties that you add because for now these cannot be renamed or deleted (you can only change their description).

Getting started

To be able to use Firebase for your Android or iOS app you need to enroll it. For that, you must create a project and then add applications to it.

  1. Open the Firebase console.
  2. Create a new project (or select an existing one).
  3. Add a new Android, iOS or web app.
  4. Follow to instructions to register the app, download the config files or perform other necessary setups.

If you need more help for setting up your app read the Firebase documentation or additional web resources.

Cordova plugin

There is an official Cordova plugin called cordova-plugin-firebase that provides push notifications, analytics, event tracking, crash reporting and other services from the Firebase platform for you Cordova application.

When you start using Firebase, make sure you have the config files properly setup (present and valid). Otherwise, your app will crash on boot or Firebase features won’t work.

Recording events and user properties

To record a user property you should call setUserProperty. This has the form:

The name is the case-sensitive name you defined in the Firebase console. In the example above the name was login_type and possible values were demo and live. The purpose of this is to indicate that for an application that supports a demo mode where the users don’t have to create an account to try the app, the user is either properly authenticated on or actually using the demo feature.

When this call is made the Debug view shows the change of the user property value in the live stream.

If you look at the recorded user properties for all following events you will see the logon_type with the demo value attached to it.

As mentioned ealier, there are a series of events that are automatically recorded. These include screen_view (collected whenever the page has changed) and user_engagement (collected periodically when the app is in foreground). However, you can send any other event, each with any number of parameters. To record events you must use the logEvent function that has the following form:

Let’s suppose that in your app users can bookmark items (whatever those items might be) but also remove them from the bookmarks (or favorites). You want to record the event of adding and removing an item. You can define an event called favorites_action with two parameters: action that can be either add or remove, and type, that indicates what kind of item was added or removed.

These are added automatically to the stream of events, recorded with both the the auto collected and user defined parameters and user properties.


All the events have several implicit parameters, including firebase_screen, firebase_screen_class, and firebase_screen_id. Screen class is the class name of the Activity, and the ID is a numerical ID that is probably hard to use to figure where the event came from. The screen name on the other hand (firebase_screen) is what you probably want to look at. This can be set with a call to setScreenName. All events will have the param firebase_screen set to the last value passed to setScreenName. Therefore, you probably want to make this call whenever the user opens a new page in your application. The call has the form:

Here is an example:

Debugging Firebase Analytics

The events recorded by Firebase are not instantly sent to the servers. Instead they are cached, archived and periodically dispatched. However, you can enable live streaming of events for debugging purposes, both on Android and iOS. This was used for all the screen shots used previously.

For Android devices:

  • To enable execute:
  • To disable execute:

For iOS devices:

  • To enable specify -FIRDebugEnabled as an argument in XCode
  • To disable specify -FIRDebugDisabled as an argument in XCode

For more information see Debugging Events.

, , , , , , Hits for this post: 5011 .

I am pleased to announce that my book on modern C++ programming has been published by PacktPub. The book is called Modern C++ Programming Cookbook and can be ordered at packtpub.com and Amazon. The ISBN of the book is 9781786465184. The complete table of contents is available below.

The front cover

The book is organized in recipes, much like a cookbook (therefore the name). These recipes are organized in sections that introduce you to the topic, list any necessary pre-requisites and then explain how to do something and how that works. Throughout 112 recipes, the book covers both language and library features from C++11, C++14 and C++17, including the libraries for strings, containers, algorithms, iterators, input/output, regular expressions, threads, filesystem, atomic operations, and utilities. Besides that, there is a chapter for patterns and idioms and one dedicated for testing frameworks, that covers everything you need to know to get started with Boost.Test, Google Test and Catch.

This book is intended for all C++ developers, regardless of their experience. The beginner and intermediate developers will benefit the most from the book in their attempt to become prolific with C++. Experienced C++ developers, on the other hand, will find a good reference for many C++11, C++14, and C++17 language and library features that may come in handy from time to time. However, the book requires prior basic knowledge of C++, such as functions, classes, templates, namespaces, macros, and others. If you are not familiar with C++ at all, you should first read an introductory book to familiarize yourself with the core aspects.

Although C++17 has not yet been ratified as an ISO standard, the final version that is up for the ballot is well defined. In my book I discuss most of the important language and library features that made it into C++17. The C++17 features discussed in the book are:

  • structured bindings
  • fold expressions
  • constexpr if
  • new attributes ([[fallthrough]], [[nodiscard]], [[maybe_unused]])
  • new type deduction rules for list initialization
  • range based for loops improvements
  • general form of lambda expressions
  • std::invoke() and std::apply()
  • static_assert changes
  • non-member container access functions std::data(), std::size(), and std::empty()
  • std::search() searchers (Boyer-Moore and Boyer-Moore-Horspool)
  • chrono changes (floor(), round(), ceil(), and abs())
  • std::any
  • std::optional
  • std::variant (2 recipes)
  • std::string_view
  • std::scoped_lock
  • filesystem library (5 recipes)
  • shared_ptr and unique_ptr changes

All the samples in the book have been tested with VC++ 2017 (where possible), GCC 7 and Clang 5.

If you do not have the latest versions of these compilers, you can try all the samples in the book with an online compiler. gcc and Clang are available at wandbox.org and VC++ is available at webcompiler.cloudapp.net.

All the language and library features discussed in the book are available with these versions of the mentioned compilers, except for a few exceptions for VC++.

At this time, the following features are still not supported in VC++:

  • structured bindings
  • fold expressions
  • constexpr if
  • searchers for std::search()

Table of contents

  1. Learning Modern Core Language Features
    • Using auto whenever possible
    • Creating type aliases and alias templates
    • Understanding uniform initialization
    • Understanding the various forms of non-static member initialization
    • Controlling and querying object alignment
    • Using scoped enumerations
    • Using override and final for virtual methods
    • Using range-based for loops to iterate on a range
    • Enabling range-based for loops for custom types
    • Using explicit constructors and conversion operators to avoid implicit conversion
    • Using unnamed namespaces instead of static globals
    • Using inline namespaces for symbol versioning
    • Using structured bindings to handle multi-return values
  2. Working with Numbers and Strings
    • Converting between numeric and string types
    • Limits and other properties of numeric types
    • Generating pseudo-random numbers
    • Initializing all bits of internal state of a pseudo-random number generator
    • Using raw string literals to avoid escaping characters
    • Creating cooked user-defined literals
    • Creating raw user-defined literals
    • Creating a library of string helpers
    • Verifying the format of a string using regular expressions
    • Parsing the content of a string using regular expressions
    • Replacing the content of a string using regular expressions
    • Using string_view instead of constant string references
  3. Exploring Functions
    • Defaulted and deleted functions
    • Using lambdas with standard algorithms
    • Using generic lambdas
    • Writing a recursive lambda
    • Writing a function template with a variable number of arguments
    • Using fold expressions to simplify variadic function templates
    • Implementing higher-order functions map and fold
    • Composing functions into a higher-order function
    • Uniformly invoking anything callable
  4. Preprocessor and Compilation
    • Conditionally compiling your source code
    • Using the indirection pattern for preprocessor stringification and concatenation
    • Performing compile-time assertion checks with static_assert
    • Conditionally compiling classes and functions with enable_if
    • Selecting branches at compile time with constexpr if
    • Providing metadata to the compiler with attributes
  5. Standard Library Containers, Algorithms, and Iterators
    • Using vector as a default container
    • Using bitset for fixed-size sequences of bits
    • Using vector for variable-size sequences of bits
    • Finding elements in a range
    • Sorting a range
    • Initializing a range
    • Using set operations on a range
    • Using iterators to insert new elements in a container
    • Writing your own random access iterator
    • Container access with non-member functions
  6. General Purpose Utilities
    • Expressing time intervals with chrono::duration
    • Measuring function execution time with a standard clock
    • Generating hash values for custom types
    • Using std::any to store any value
    • Using std::optional to store optional values
    • Using std::variant as a type-safe union
    • Visiting a std::variant
    • Registering a function to be called when a program exits normally
    • Using type traits to query properties of types
    • Writing your own type traits
    • Using std::conditional to choose between types
  7. Working with Files and Streams
    • Reading and writing raw data from/to binary files
    • Reading and writing objects from/to binary files
    • Using localized settings for streams
    • Using I/O manipulators to control the output of a stream
    • Using monetary I/O manipulators
    • Using time I/O manipulators
    • Working with filesystem paths
    • Creating, copying, and deleting files and directories
    • Removing content from a file
    • Checking the properties of an existing file or directory
    • Enumerating the content of a directory
    • Finding a file
  8. Leveraging Threading and Concurrency
    • Working with threads
    • Handling exceptions from thread functions
    • Synchronizing access to shared data with mutexes and locks
    • Avoiding using recursive mutexes
    • Sending notifications between threads
    • Using promises and futures to return values from threads
    • Executing functions asynchronously
    • Using atomic types
    • Implementing parallel map and fold with threads
    • Implementing parallel map and fold with tasks
  9. Robustness and Performance
    • Using exceptions for error handling
    • Using noexcept for functions that do not throw
    • Ensuring constant correctness for a program
    • Creating compile-time constant expressions
    • Performing correct type casts
    • Using unique_ptr to uniquely own a memory resource
    • Using shared_ptr to share a memory resource
    • Implementing move semantics
  10. Implementing Patterns and Idioms
    • Avoiding repetitive if…else statements in factory patterns
    • Implementing the pimpl idiom
    • Implementing the named parameter idiom
    • Separating interfaces from implementations with the non-virtual interface idiom
    • Handling friendship with the attorney-client idiom
    • Static polymorphism with the curiously recurring template pattern
    • Implementing a thread-safe singleton
  11. Exploring Testing Frameworks
    • Getting started with Boost.Test
    • Writing and invoking tests with Boost.Test
    • Asserting with Boost.Test
    • Using test fixtures with Boost.Test
    • Controlling output with Boost.Test
    • Getting started with Google Test
    • Writing and invoking tests with Google Test
    • Asserting with Google Test
    • Using test fixtures with Google Test
    • Controlling output with Google Test
    • Getting started with Catch
    • Writing and invoking tests with Catch
    • Asserting with Catch
    • Controlling output with Catch

Credits

It took about eight months to complete this book and I got a lot of help from several people that I would like to thank to. First of all, is the team at PacktPub; although there were more people involve that I actually am aware of, I would like to thank Anurag Ghogre, Subhalaxmi Nadar and Nitin Dasan for all the help they provided throughout this time and the work they put in the project, as well as the other people that were involved with this book. I also want to thank David Corbin, whom I know for many years as “The CPU Wizard”, for reviewing the book and providing valuable feedback that made the book better. And last, but not least, I want to thank my wife for putting up with me through the many days and nights that I worked on this project.

, , , , , , , , Hits for this post: 17860 .