Articles & Books

Bitesize Modern C++: enum class—Glennan Carnie

A simple and complete explanation of the enum:

Bitesize Modern C++: enum class

by Glennan Carnie

From the article:

Enumerated types in C++ give a trivial simulation of symbolic types – that is, objects whose instances have unique, human-readable values. In C++ enumerations are essentially named integers that are either assigned values implicitly by the compiler or explicitly by the programmer (or a combination of both)...

The State of C++ – Is it Back or Not?—Arne Mertz

A personal opinion from Arne Mertz about the state of C++. Always interesting.

The State of C++ – Is it Back or Not?

By Arne Mertz

From the article:

The notion of C++ coming back to where it was before the raise of languages like Java and C#, or even the comparison of C++ now and then has a serious flaw: It is an isolated view of only the languages, competing for popularity in a fixed surrounding.

The Four Polymorphisms in C++—Peteris Krumins

C++ has more than one ways to express polymorphism. Discover the nomenclature and read examples on all of them in the following article :

The Four Polymorphisms in C++

by Peteris Krumins

From the article:

(...) These polymorphisms also go by different names in C++ :

  • Subtype polymorphism is also known as runtime polymorphism.
  • Parametric polymorphism is also known as compile-time polymorphism.
  • Ad-hoc polymorphism is also known as overloading.
  • Coercion is also known as (implicit or explicit) casting.

Safety: off - How not to shoot yourself in the foot with C++ atomics— Anthony Williams

Guidelines for how to use C++ atomics safely in our code using worked examples.

Slides and code and for my ACCU 2015 presentation

by Anthony Williams

From the article:

It's now two months since the ACCU 2015 conference in Bristol, UK, so I thought it was about time I posted my slides.

This year my presentation was titled "Safety: off - How not to shoot yourself in the foot with C++ atomics". I gave a brief introduction to the C++ atomics facilities, some worked examples of usage, and guidelines for how to use atomics safely in your code.

The slides are available here, and the code examples here.

Time To Get Moving!—Tony DaSilva

A nice "in a nutshell" about why you should run, not walk, to take advantage of move semantics:

Time To Get Moving!

by Tony DaSilva

From the article:

Starting from C++11 on, we not only get those operations for free for our user-defined types, we also get these turbo-boosters:

  • a “free” move constructor
  • a “free” move assignment operator

In addition, all of the C++ standard library containers have been “move enabled“.

When I first learned how move semantics worked and why this new core language feature dramatically improved program performance over copying, I started wondering about user-defined types that wrapped move-enabled, standard library types. For example,  check out this simple user-defined Msg structure that encapsulates a move-enabled std::vector...

C++ and Facebook Moments: Facebook code blog, Techworld

fb-moments.PNGHere are two notable articles related to C++'s central role in Facebook's Moments app, released yesterday.

The first is the announcement on the Facebook code blog:

Under the Hood: Building Moments

by Ashwin Bharambe, Zack Gomez, and Will Ruben

From the article:

... There are many alternatives for sharing code between mobile platforms. We wanted to optimize for fast iteration, app performance, and native look and feel. After weighing the alternatives, we chose to write the UI in platform-specific code and the business logic in shared code using C++. Traditionally, C++ is known for providing high performance while lacking easy memory management and higher-level abstractions. However, using modern C++11 features such as std::shared_ptr reference counting, lambda functions, and auto variable declarations, we were able to quickly implement highly performant, memory-safe code...

The growing use of C++ for cross-platform shared code in mobile apps is not a new technical story in itself -- last year's CppCon had multiple sessions about doing this including from Dropbox and Microsoft Office -- but even the mainstream press is starting to notice this is happening more often:

C++: It is back to the future for Facebook's new photo-sharing app

by Joab Jackson, TechWorld

From the article:

Faced with the burgeoning problem of maintaining a code base for multiple, incompatible mobile applications, Facebook engineers turned their noses up at HTML5 and trendy development programmes and went back to the 70s [sic] for an answer.

By choosing the C++ programming language for its new Moments photo-sharing application, Facebook is able to maintain a single code base for much of the app, which runs on both iOS and Android devices.

"It is somewhat of a surprising choice," admitted Ashwin Bharambe, one of the Facebook developers who created Moments, about the use of C++. "There are more and more people trying to do this in order to share code across different platforms." ...

Folding Expressions—Marco Alesiani

A new blog post containing runnable code from the Italian C++ Community:

Folding Expressions

by Marco Alesiani

From the article:

C++17, scheduled by 2017 at the time of writing, will introduce fold expressions into play and significantly broaden parameter packs scopes of use [...]

template<typename F, typename... T>
void for_each(F fun, T&&... args)
{
    (fun (std::forward<T>(args)), ...);
}

The sample above uses fold expressions together with the comma operator to create a simple function that calls the provided lambda per each one of the supplied arguments with perfect forwarding. [...]

HPX and C++ Dataflow(await)—Hartmut Kaiser

Uses/Implementation/Discussion about await feature in modern C++.

HPX and C++ Dataflow

by Hartmut Kaiser

From the article:

We have done some experiments with a preliminary implementation of await in Visual Studio 2015RC. We were able to integrate it well with the futures in HPX and the results are very promising. Unfortunately, the await keyword (and resumable functions) will only be available in all mainstream compilers years from today. So for now we will have to make do with our poor-man’s-await –dataflow.

In any case, if you want to try things out (including dataflow), please fork HPX from our Github site and tell us what you think.

10 tips to be productive in CLion, cross-platform C/C++ IDE—Anastasia Kazakova

An article on how to improve your productivity when using CLion IDE.

10 tips to be productive in CLion

by Anastasia Kazakova

From the article:

Judging from my own experience as a developer, many C/C++ developers dismiss the idea that an IDE can make them more productive. Because what could be better than the simple and quick Vim or Emacs? Well, let me show you. These 10 CLion tips can take you to a new level of productivity, by letting you focus on the important and complicated tasks while the IDE handles routine jobs for you.

From Smart Code Completion to Inline Variables View...