
This month’s C++ London meetup features two talks – the first on C++/Python integration and the second on C++ iterators.
Foreign Function Interface Generator (FFIG) – Jonathan Coe
Jonathan presented his hobby project, FFIG, largely written on the train during his commute (!).
I want to be able to write C++ code and call it from Python without doing any extra work
He explained that existing solutions (Boost::python and SWIG) generate interfaces that bind you to a specific binary Python implementation. Whilst a work in progress, FFIG’s generated libraries are Python library independent (meaning you can compile once and call from multiple Python libraries).
FFIG generates a C-API on top of your C++ code, which eliminates any classes/structs, but provides a library readily callable from Python. It also generates a Python (or Ruby) library that layers the objects over the C-API, to restore the original interface. A key lesson learned during development was to hide any ownership concerns from the Python layer.
Why Iterators Got It Wrong – Arno Schödl
Arno has developed a range-like library within his firm (Think-Cell), which addresses some features of iterators perceived as ugly:
// Iterators returned by begin() and end() are asymmetrical
auto it = collection.begin(); // start of a non-empty collection
std::cout << *it; // ok - prints the first element of the collection
auto it2 = collection.end(); // end of a non-empty collection
std::cout << *it2;// error - undefined behaviour, end() returns 1 past the last element!
// Algorithms may return a valid element or a sentinel "border" indicator
std::vector<int> v1{0, 1, 2, 3, 4}, v2{};
auto result1 = std::find(std::begin(v1), std::end(v1), 2);
std::cout << *result1; // ok
auto result2 = std::find(std::begin(v2), std::end(v2), 2);
std::cout << *result2; // error - de-referencing end again
The summary was that his library distinguished between elements and borders instead of using iterators. Once rolled out through the codebase, this made the code clearer and avoided any chance of undefined behaviour. However, I think the availability of Eric Niebler’s Range library (or simple higher-order functions) make the STL so easy to use that these concerns shouldn’t put off new developers.
This book was a lucky, random find in a charity book shop. I hadn’t read anything by this author before, but the book was thoroughly enjoyable. It’s primarily a Science Fiction book – the hero, Admiral Jack Geary, guides his fleet of starships across the galaxy back to the home system, Varandal, encountering numerous enemies (some human, some alien) on the way. But he also has to overcome political challenges and man-management issues within the fleet and in the government back home. 
Roger Orr gave this month’s ACCU presentation on Making Templates Easier in C++. He showed two techniques that people commonly use to tailor template implementations for specific types: Tag Dispatch and SFINAE (via enable_if).
The premise of this book is that the brilliant Robert Puller has been convicted of treason against the USA and is being held in a maximum security military prison. His brother, the gifted investigator John Puller, still believes in him, even when he escapes during a storm. John Puller works with the intrepid Veronica Knox to investigate the escape and to clear his brother’s name. They focus on the witnesses who gave testimony against Robert Puller. If he is innocent, they can’t be, so the investigators have to uncover the truth behind their lies.
This Harry Bosch thriller starts with an investigation into the murder of a Chinese convenience store owner. It happens that this very man gave shelter to Harry in his shop during a riot, so he resolves to do everything he can to track down the culprit. During the investigation, the author answers a lingering question – how did Harry suddenly find himself looking after his teenage daughter, in later books in the series? The daughter, Madeline, was living with her mother Eleanor Wish in Hong Kong – they become an integral part of this story when a Triad gang decide to ward off Harry’s murder investigation by kidnapping Maddie. 

A friend sent me a link to some Jack Reacher quotes and I was delighted to discover that it listed a book in the series that I hadn’t read – “Running Blind”. I ordered it immediately – alas when it arrived, it turned out to be “The visitor”, a book I had already read, just published under another name in the U.S. 
I was lucky to get a ticket to hear Andrew Blake’s
The lecture covered the history of machine vision over the last 50 years, the rise and fall of different approaches to AI over the decades, and finally the recent successes of analysis-by-synthesis and empirical recognisers.
This is the third novel by Mark Gimenez that features A. Scott Fenney, a brilliant Dallas lawyer. His way of life was changed dramatically when forced to defend a young woman against a murder charge in 
I’ve been learning Python for a few months and am starting to use it at work, so I thought it was about time to read a book about Python. This book has been excellent. No only does it follow format of the time-honoured ‘Effective’ series pioneered by Scott Meyers, it also features practical, useful code examples. In particular, his JsonMixin class was immediately relevant to some work I’ve been doing to generically serialise to/from JSON documents – see Item 26 “Use Multiple Inheritance Only for Mix-In Utility Classes”.
