Articles & Books

A Casting Show -- Arne Metz

In this next article Arne Mertz describes different type casts.

A Casting Show

by Arne Mertz

From the article:

In C++ there are two ways of type conversions: implicit and explicit type conversions. The latter are called type casts and they are what this post is about.

Visual C++ 2015 Brings Modern C++ to the Windows API--Kenny Kerr

Kenny Kerr's article in MSDN Magazine describes how Modern C++ can be used with Windows API to develop efficient and elegant libraries:

Visual C++ 2015 Brings Modern C++ to the Windows API

by Kenny Kerr

From the article:

It’s somewhat ironic that C++ is finally modern enough for COM. Yes, I’m talking about the Component Object Model that has been the foundation for much of the Windows API for years, and continues as the foundation for the Windows Runtime. While COM is undeniably tied to C++ in terms of its original design, borrowing much from C++ in terms of binary and semantic conventions, it has never been entirely elegant. Parts of C++ that were not deemed portable enough, such as dynamic_cast, had to be eschewed in favor of portable solutions that made C++ implementations more challenging to develop. Many solutions have been provided over the years to make COM more palatable for C++ developers. The C++/CX language extension is perhaps the most ambitious thus far by the Visual C++ team. Ironically, these efforts to improve Standard C++ support have left C++/CX in the dust and really make a language extension redundant.

LLDB is Coming to Windows--Zachary Turner

A new article on the LLVM blog speaks about LLDB coming on Windows soon:

LLDB is Coming to Windows

by Zachary Turner

From the article:

We've spoken in the past about teaching Clang to fully support Windows and be compatible with MSVC.  Until now, a big missing piece in this story has been debugging the clang-generated executables.  Over the past 6 months, we've started working on making LLDB work well on Windows and support debugging both regular Windows programs and those produced by Clang...

Don’t Try Too Hard! – Exception Handling -- Arne Mertz

Arne Mertz describes in his recent article insights about exception handling.

Don’t Try Too Hard! – Exception Handling

by Arne Mertz

From the article:

Among C++ developers there often appears to be a misconception about what it means to deal with code that can throw exceptions. The misconception is that the possibility of exceptions means one has to try and catch often and almost everywhere. I will try to explain why I think that is wrong and where I think try/catch is appropriate and where not.

Providing Explicit Specializations for Non-Template Members of Class Template -- Pavel Frolov

One of the lesser-known features of C++ templates.

Providing Explicit Specializations for Non-Template Members of Class Template

by Pavel Frolov

From the article:

C++ is full of surprises (albeit not always good ones grin. It is a well known fact that you can provide explicit specializations for function templates and class templates. But it was a total surprise to me, that you can provide explicit specializations for non-template members of class template without specializing the class template itself!

Type safe handles in C++--Emil Ernerfeldt

Some time ago, Emil Ernerfeldt wrote about type safe handles. Simple and interesting.

Type safe handles in C++

by Emil Ernerfeldt

From the article:

Let's say you have a system of resources and you identify them using integers as handles. These integers are meaningless to the user, but internally they may be indices into an array, or just a running count...

Why does a single integer assignment statement consume all of my CPU? -- Raymond Chen

A fresh here's-the-code-spot-the-performance-problem analysis.

Why does a single integer assignment statement consume all of my CPU?

by Raymond Chen

From the article:

Profiling showed that over 80% of the time spent by Calculate­The­Value was inside the Set­Int32 method call, in particular on the line

  *reinterpret_cast<int32_t *>(m_data) = value;

Why does it take so much time to store an integer to memory, dwarfing the actual computation to calculate that integer?

Spoiler hint: [Chaotic neutral]

Operator Overloading -- Arne Mertz

Arne Mertz describes in a series of articles the principles of operator overloading.

Operator Overloading

Operator Overloading: Common Practice

by Arne Mertz

From the articles:

Operators can be used to make user defined classes act like known types, e.g. like numbers, pointers and iterators. That way they facilitate the usage of those classes. They can also be used to make your objects do whatever you want them to do, for example build structures that save the operations for later evaluation. The latter is especially useful for building embedded DSLs and gives enough subject matter for a whole series of blog posts. [The first] post will cover the former use of operator overloading, i.e. writing operators that behave like “normal” operators.

... In [the second] post I will go into the details and write a bit about each operator and how a straight forward implementation might look if the operator is meant to work similar to built in operators.

 

The Rule of Zero -- Glennan Carnie

A complementary guideline to help to simplify the application code, without risking resource management issues.

The Rule of Zero

In a previous article – "The Rule of the Big Four (and a half)" we looked at resource management policies in C++.

Resource management is the general term for using the mechanisms in C++ to ensure that resources – files, dynamic memory, sockets, mutexes, etc – have their lifetimes automatically controlled so as to prevent resource leaks, deadlocks, etc. C++ refers to these mechanisms as RAII/RDID ( “Resource Acquisition Is Initialisation / Resource Destruction is Deletion”)

In this article we’ll have a look at a complementary guideline to help simplify your application code, without risking resource management issues – The Rule of Zero.

If you’re not familiar with the concepts of resource management I’d highly recommend having a look at the whitepaper before reading on.