Operator Overloading – Introduction to Boost.Operators -- Arne Metz

Arne Mertz goes into the details of using boost operators.

Operator Overloading – Introduction to Boost.Operators, Part 1

Operator Overloading – Introduction to Boost.Operators, Part 2

by Arne Mertz

From the articles:

In my first two posts about operator overloading I have written about the basics and common practice. This post shows some lessons from the common practice post on a concrete example and then introduces to Boost.Operators, a library that conveniently reduces the boilerplate involved when overloading multiple operators for a class.

Operators Travel in Packs

If we look at the list of operators, we see that there are about 50 of them, and many of them can be overloaded in different ways. Even if we restrict ourselves to a few operations that make sense for a given class, then one of those operations often brings two or more operators.

 

SFINAE std::result_of? Yeah, right!--Scott Prager

On the matter of having a useful error message:

SFINAE std::result_of? Yeah, right!

by Scott Prager

From the article:

Return type deduction pre-decltype and auto could really make one mad. Back then, if you wanted a function object, you had to make it "adaptable", meaning it had to inherit from std::unary_ or binary_function and define its first_argument_type, second_argument_type, and result_type. There had been no concept of "transparent functors" allowing us to pass polymorphic functions to higher order functions (like std::plus<> to std::accumulate). For an example of programming in these dark ages, check out the FC++ FAQ.

 

CppCon 2014 C++11 in the Wild: Techniques from a Real Codebase--Arthur O'Dwyer

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

C++11 in the Wild: Techniques from a Real Codebase

by Arthur O'Dwyer

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

This talk presents several reusable constructs from a production C++11 codebase, each of which would not be possible without C++11's new features. Auto() is what Alexandrescu's ScopeGuard looks like after a dozen years of C++ evolution. make_iterable() constructs a container from a pair of iterators, enabling simple "foreach" iteration over legacy containers. spaceship() is an efficient "strcmp" for tuples. Time permitting, we'll look at some more arcane code samples.

Type Deduction and Braced Initializers--Arne Mertz

If you are confused about the topic, read this article:

Type Deduction and Braced Initializers

by Arne Mertz

From the article:

I just finished watching a talk from CppCon 2014 by Scott Meyers: Type Deduction and Why You Care. All in all it was a very interesting and entertaining talk, and I learned a thing or two, especially about the combination of type deduction and braced initializers. Since this blog is about simplifying the use of C++, I want to have a short look at that special combination and derive a rule of thumb from it...

CppCon 2014 Using C++ on Mission and Safety Critical Platforms--Bill Emshoff

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

Using C++ on Mission and Safety Critical Platforms

by Bill Emshoff

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

The Joint Strike Fighter (JSF) is the first major DOD aircraft program to use C++. Much of this software is either safety critical or mission critical and so must be written in such a way as to be clear, readable, unambiguous, testable, and maintainable. We discuss the driving requirements behind the standard and its evolution. We give a quick overview of our standard and discuss how it differs from later standards such as MISRA C++. We discuss lessons learned over our nine year history of applying the standard to a large embedded software program. We also address ambiguities in rules and difficulties with automated checking of conformance with the standard.

Video Tutorial: Handle-based entity management -- Vittorio Romeo

Almost every C++ application and game deals with entity management.

Video Tutorial -- Handle-based entity management

By Vittorio Romeo

From the tutorial:

Entities are usually self-contained objects that...

  • ...store data and/or logic.
  • ...are tied a specific concept (e.g. an UI widget, or a 3D model).
  • ...we need to keep track of.
  • ...can either be alive or dead.
  • ...are extremely often used in groups.

Problem: we need to keep track of specific entity instances, and iterate on every instance. We also need to remove dead entities and add new entities.

Keeping track of specific instances is easily solved with pointers and smart pointers.
Fast-iteration of a group of objects with the same type is achieved with cache-friendly memory locality and no indirection.
Adding and removing entities stored in a cache-friendly manner invalidates existing pointers.

How can we facilitate instance tracking/addition/removal and still allow fast iteration?

In this video, we will create a generic container that stores objects in a cache-friendly way, allows to keep track of specific object instances and also allows addition and removal of entities. 
 

 

John Lakos interviews Alexander Stepanov and Daniel Rose on their new Book

Published on InformIT in which John Lakos interviews Alexander Stepanov and Daniel Rose about various aspects of generic programming and modern C++.

From Mathematics to Generic Programming: An Interview with Alexander Stepanov and Daniel RoseFrom Mathematics to Generic Programming

 

John Lakos interviews Alexander Stepanov and Daniel Rose, authors of From Mathematics to Generic Programming, on their new book, why it applies to everyday programmers, and their positions on some closely related technical issues — including value semantics, concepts, contracts, and polymorphic memory resources — facing the C++ Standards Committee today.

Fighting off memory leaks and errors (C++11) -- Kacper Kołodziej

This article talks about how modern C++ idioms could be used to avoid memory leak and errors.

Fighting off memory leaks and errors (C++11)

by Kacper Kolodziej

From the article:

Modern tools provided with C++11's standard library make fight with memory leaks and errors easier and more effective. Sometimes problems which are seemingly not dangerous might put an end to your application. We are going to learn how to find and avoid them.
 

Counting bits -- Jens Weller

How to generate random bytes and how generic programming allow/support reuse code for different types.

   Counting bits

   by Jens Weller

From the article:

I did a bit of fun coding. I'm currently thinking on how to generate random bytes, for example the 16 random bytes for the initialization vector of AES. The mersenne twister RNG is known to give very good randomness, so it would be a possible an easy source. An std::array<uint32_t,4> would be a good container, filled with generate. But first, I wanted to know, how random is the mersenne twister really? So, when counting the bits in the result of a few thousand calls to a rng, the distribution should be even. So, today I wrote code that counts bits, and tested it on the mersenne twister.