Articles & Books

A visitor’s guide to C++ allocators -- Thomas Köppe

The standard library allocators are one of the more mysterious parts of namespace std, as well as one of the more flexible parts. In this "under construction" article and GitHub repo, Thomas Köppe undertakes to demystify the feature.

A visitor’s guide to C++ allocators (repo)

by Thomas Köppe

From the README:

This repository contains a collection of documents that describe the allocator concept in the standard library of C++11 and beyond. The main guide covers the following topics.

  • Allocator traits
  • Statefulness
  • Fancy pointers
  • Allocator propagation in breadth (container copy, POC{CA,MA,S}) and depth (scoped_allocator_adaptor)

Start reading with the main guide.

Furthermore, there are several worked-out end-to-end examples:

The code for the end-to-end examples is available separately in the example_code directory.
 

Thoughts on C++14 -- Jens Weller

Jens Weller gives a nice perspective on the C++ landscape in 2014.

Thoughts on C++14

by Jens Weller

From the article:

Yesterday we could read on isocpp.org that C++14 has been approved and will now become a valid ISO Standard. Great news for everyone in the C++ land! ...

But there is something else that makes C++14 for me special...

Using Varadic Templates for a Signals and Slots Implementation in C++ -- Paul Cook

Fresh on GameDev.net:

Using Varadic Templates for a Signals and Slots Implementation in C++

By Paul Cook

From the article:

Abstract

Connecting object instances to each other in a type-safe manner is a well-solved problem in C++ and many good implementations of signals and slots systems exist. However, prior to the new varadic templates introduced in C++0x, accomplishing this has traditionally been complex and required some awkward repetition of code and limitations.

Varadic templates allow for this system to be implemented in a far more elegant and concise manner and a signals/slots system is a good example of how the power of varadic templates can be used to simplify generic systems that were previously difficult to express. ...

C++11/14 Idioms I Use Every Day -- Paul Cechner

Start your Monday the right way by sending this to three of your friends who are new to (modern) C++:

C++11/14 Idioms I Use Every Day

by Paul Cechner

From the article:

Most attention on the new C++ has focused on the changes that provide functionality and performance that was previously not possible, both library enhancements (chrono, regex, smart pointers, and stuff to help with lambdas for example) and core language enhancements (perfect forwarding, variadic templates, the new memory model and threading capabilities, initialiser lists and the like). This functionality will impact us all in helping to write more correct code and efficient libraries, but often will only be relevant in certain parts of our code.

But the first thing that struck me when I started using C++11 was the smaller features that I could take advantage of every time I put my fingers to the keyboard. These are the things that make code more concise and simple and allow me to present my intentions more clearly. ...

Stroustrup: Why the 35-year-old C++ still dominates 'real' dev -- Paul Krill, Infoworld

infoworld.PNGToday in Infoworld:

Stroustrup: Why the 35-year-old C++ still dominates 'real' dev

C++ inventor details the language's latest changes and assesses the strengths and weaknesses of its competitors

by Paul Krill, Infoworld

From the interview:

Bjarne Stroustrup designed the C++ language in 1979, and the general-purpose language for systems programming has become a mainstay for developers everywhere, despite competition from Java, JavaScript, Python, Go, and Apple's newly unveiled Swift.

Now a technologist at Morgan Stanley and a professor at both Columbia University and Texas A&M University, Stroustrup spoke with InfoWorld Editor at Large Paul Krill about C++'s role today and about other happenings in software development, including Google's Go and Apple's Swift languages. ...

Quick Q: Does make_shared avoid an extra allocation for the reference counts? -- StackOverflow

A: Yes, make_shared is your friend!

Recently on SO:

What happens when using make_shared

I'm interested if these two lines of code are the same:

shared_ptr<int> sp(new int(1)); // double allocation?
shared_ptr<int> sp(make_shared<int>(1)); // just one allocation?

If this is true could someone please explain why is it only one allocation in the second line?

Overload 122 is available

overload-122.PNGOverload 122 is now available. It contains the following C++-related articles, and more:

 

Overload 122

Musings on Python -- By a C++ Developer

Python and C++ are very different languages. Sergey Ignatchenko walks through things in Python that can confuse a C++ programmer

Activatable Object

Using locks will slow down threaded code. Len Holgate demonstrates how an Activatable Object can reduce the time spent blocked.

HTTP and HTTPS in Qt

How to handle HTTP and HTTPs requests in Qt

HTTP and HTTPs in Qt

by Jens Weller

From the article:

Last week I started to work on an old project again: My own feed reader. I found the code 2 weeks a go on an old USB Stick, and decided to refactor it into a useful state. This involved dealing with HTTP via QNetworkAccessManager.