Codexpert – 2016 Articles Summary

C++ Programming Language Guidelines Support Library Review: span<T> Guidelines Support Library Review: string_span<T> Microsoft Libraries Easy PNG Resource Loading with MFC – Part 1 MFC Static Control Using Direct2D and DirectWrite MFC Static Control Using Direct2D and DirectWrite (updated) MFC Support for DirectWrite – Part 7: A Step to Custom Rendering Getting Direct2D, DirectWrite and … Read more

Guidelines Support Library Review: string_span<T>

In a previous post I have introduced the span<T> type from the Guidelines Support Library. This is a non-owning range of contiguous memory recommended to be used instead of pointers (and size counter) or standard containers (such as vector or array). span<T> can be used with strings, but the Guidelines Support Library provides a different … Read more

Guidelines Support Library Review: span<T>

The Guidelines Support Library is a Microsoft implementation of some of the types and functions described in the C++ Core Guidelines maintained by the Standard C++ Foundation. Among the types provided by the GSL is span<T> formerly known as array_view<T>. This article is an introduction to this type. span<T> is a non-owning range of contiguous … Read more

Codexpert – 2015 Articles Summary

Microsoft Libraries and C++ Programming Language Using Lambdas in MFC Applications – Part 1: Sorting Arrays Presents how to sort MFC arrays using lambda expressions (C++11 and next). Using Lambdas in MFC Applications – Part 2: Replacing Callback Functions Shows examples of using lambda expressions (including nested lambdas) in MFC applications for replacing callback functions. … Read more

Using Lambdas in MFC Applications – Dealing with C++ REST SDK

C++ REST SDK (also known as Casablanca) offers support for HTTP client/server, JSON, URI, asynchronous streams, WebSockets client, oAuth and PPL Tasks. We can get C++ REST SDK from CodePlex  or use the one shipped with Visual Studio 2013. This article gives suggestions of how to set up a Visual C++ project (particularly one that … Read more

Binary literals and digit separators

The C++14 standard provides two new small features to the language: binary literals and digit separators. They are already available in Clang 3.4 and GCC 4.9 and now Visual Studio 2015 RC has implemented them. They may not be something you can’t live without, but sometimes it’s convenient to have them. Let’s have a look. … Read more

Using Lambdas in MFC Applications – Replacing Callback Functions

According to C++11 Standard, stateless lambdas, i.e. having an empty lambda introducer or capture no variables, are implicitly convertible to function pointers. Visual C++ in Visual Studio 2012 and newer, supports this feature. Moreover, in Visual C++ stateless lambdas are convertible to function pointers with arbitrary calling conventions. This is great if have to deal … Read more

Using Lambdas in MFC Applications – Sorting Arrays

Beginning with Visual Studio 2010 which supports lambda expressions introduced by C++11 standard, you can handily sort an MFC array like in the following example: Sorting CStringArray by using a lambda expression // Example #1 // … CStringArray arr; arr.Add(_T(“John”)); arr.Add(_T(“Zorro”)); arr.Add(_T(“Sandy”)); arr.Add(_T(“Jimmy”)); // … bool bAscending = true; // … std::sort( arr.GetData(), // position … Read more

Codexpert – 2014 Articles Summary

Microsoft Libraries Multiple-View File Explorer Shows how to easily make a Windows file manager with multiple views by using MFC framework and IExplorerBrowser interface. MFC Support for Direct2D – Part 1 Using the MFC D2D classes for making a simple image viewer. MFC Support for Direct2D – Part 2 Demonstrates how to easily make a … Read more

C++11: Let’s Write a “Hello Lambda!”

A lambda expression (aka lambda function), introduced in C++11 standard, is a simplified notation for defining an anonymous function object. However, its syntax and using may look weird for many people so let’s try to make a simple program to accommodate with it. // Example #1 #include <iostream> int main() { [] () mutable throw() … Read more