(Not) detecting bugs—Andrzej KrzemieĊ„ski

Undefined behaviour can be dangerous.

(Not) detecting bugs

by Andrzej Krzemieński

From the article:

The following code contains a bug. A developer has spent quite some time looking for the source. The intent of this code is to iterate over two vectors simultaneously, from the first up to the one-before-last element. Thus the most interesting tools that will be employed will be boost::zip_iterator and std::prev.

#include <boost/iterator/zip_iterator.hpp>
#include <boost/tuple/tuple.hpp>
#include <vector>

using zip_iter = boost::zip_iterator<
int main()
  std::vector<int> v1 = {1, 2, 3, 4, 0};
  std::vector<int> v2 = {2, 3, 5, 7, 0};
  zip_iter beg {boost::make_tuple(v1.begin(), v2.begin())};
  zip_iter end {boost::make_tuple(v1.end(), v2.end())};
  auto process = [](zip_iter::reference){};
  std::for_each(beg, std::prev(end), process);

C++Now 2017 Call for Submissions is Live

C++Now 2017 will be held in Aspen, May 15–20, 2017.

C++Now 2017 Call for Submissions

From the invitation:

C++Now builds upon the resounding success of previous BoostCon and C++Now conferences, We look forward to considering your proposals, among those from leading speakers from the entire C++ community, to make C++Now 2017 even better.

The C++Now Conference is dedicated to discussion and education about C++, an open and free language and standard.  Our Conference will focus on discussion and education about open source software usage and developments in the C++ developer and user community. To reflect the breadth of the C++ and Boost communities, the conference includes sessions aimed at three constituencies: C++ and Boost end-users, hard-core library and tool developers, and researchers pushing the boundaries of computing. The program fosters interaction and engagement within and across those groups, with an emphasis on discussion.

As a multi-paradigm language, C++ is a melting pot with the most compelling ideas from other programming communities blended in powerful ways. Historically, some of the most popular sessions at C++Now have highlighted these concepts, from DSLs to functional programming to transactional memory and more.  Bring your C#, Python, Ruby or Haskell influences to bear in an environment that will broaden their exposure.

Presentations at C++Now 2017 should generally focus on the now established C++11 and C++14 standards, the upcoming C++17 standard, and how those standards shape C++’s future. However, by no means is this intended to restrict the topics of proposals we hope to see. Any other topic related to C++, as described below, is suitable for submission.

This year’s window for submitting is shorter than normal. Submissions must be in by February 3rd, less than four weeks away.

More Meeting C++ 2016 videos are online!

A week full of video editing brings the first batch of Meeting C++ 2016 videos online:

More videos are online!

by Jens Weller

Meeting C++ 2016 Playlist

From the article:

With today, almost all videos from the A and all videos of the D Track are online. There is a recording issue with one talk in the A track, which might get resolved in 2017. Also since today, the Meeting C++ YouTube channel has more then 400k views!

The full video set you can find in the Meeting C++ 2016 Playlist, the newest videos are easily found by visiting the Meeting C++ YouTube channel or subscribing to this RSS feed.

Why you should use Boost.MultiIndex (Part I)—David Gross

Did you know that container?

Why you should use Boost.MultiIndex (Part I)

by David Gross

From the article:

Although Boost.MultiIndex is a pretty old library — introduced in Boost 1.32, released in 2004 — I found it rather unsung and underestimated across the C++ community in comparison to other non-standard containers.

In this article, split into multiple parts, I will highlight all the benefits you can get using boost::multi_index_container instead of the standard containers: faster, cleaner and simpler code.

The Case for Optional References—Tristan Brindle

And why not simply use a pointer?

The Case for Optional References

by Tristan Brindle

From the article:

I have a confession to make. Whenever I’ve come across code that looks like this:

struct example {
    example() = default;

    example(std::string& s) : str_{s} {}

    boost::optional<std::string&> str_{};

there is a little voice inside my head that whispers “why didn’t you just use a pointer?”. Like so, for instance:

struct example {
    example() = default;

    example(std::string& s) : str_{&s} {}

    std::string* str_ = nullptr;

This is equivalent to the first example, except that it’s slightly less typing, it doesn’t have any dependencies, and feels in some sense “cleaner”. I personally have always preferred it.

Except, I was wrong. After attending Bjarne Stroustrup’s keynote and this excellent talk at Cppcon this morning, I’m persuaded that optional references are a good thing. In this post I hope to be able to convince you of the same...

CppCon 2015 Boost Units Library for Correct Code—Robert Ramey

Have you registered for CppCon 2016 in September? Don’t delay – Late registration is open now.

While we wait for this year’s event, we’re featuring videos of some of the 100+ talks from CppCon 2015 for you to enjoy. Here is today’s feature:

Boost Units Library for Correct Code

by Robert Ramey

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

I will give a presentation on the Boost Units library.

This library implements a zero runtime facility for performing dimensional analysis checking and automatic units conversion on C++ expressions. I have found this indispensable for coding scientific programs involving a variety of complex physical units. The documentation of the Boost Units library is totally complete and accurate, but totally inpenetrable. I had to spend way too much time figuring out how to use this. By attending this meeting, you're going to avoid this pain and just get the benefit of simpler programs that contain fewer bugs.

CppCon 2015 Racing The File System—Niall Douglas

Have you registered for CppCon 2016 in September? Don’t delay – Registration is open now.

While we wait for this year’s event, we’re featuring videos of some of the 100+ talks from CppCon 2015 for you to enjoy. Here is today’s feature:

Racing The File System

by Niall Douglas

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Almost every programmer knows about and fears race conditions on memory where one strand of execution may concurrently update data in use by another strand of execution, leading to an inconsistent and usually dangerous inconsistent read of program state. Almost every programmer therefore is aware of mutexes, memory ordering, semaphores and the other techniques used to serialise access to memory.

Interestingly, most programmers are but vaguely aware of potential race conditions on the filing system, and as a result write code which assumes that the filing system does not suddenly change out from underneath you when you are working on it. This assumption of a static filing system introduces many potential security bugs never mind ways of crashing your program, and of course creating data loss and corruption.

This workshop will cover some of the ways in which filing system races can confound, and what portable idioms and patterns you should employ to prevent misoperation, even across networked Samba shares. Finally, an introduction of the proposed Boost library AFIO will be made which can help application developers writing filing system race free code portably.