April 2017

C++ Debugging and Diagnostics—Adam Welch

A quick tour of the Visual Studio native debugger and how it can help you in all areas of your C++ development:

C++ Debugging and Diagnostics

by Adam Welch

From the article:

Debugging is one of the cornerstones of software development, and it can consume a significant portion of a developer’s day.  The Visual Studio native debugger provides a powerful and feature-rich experience for finding and fixing problems that arise in your applications...

CppCast Episode 96: Jewelbots with Sara Chipps

Episode 96 of CppCast the only podcast for C++ developers by C++ developers. In this episode Rob and Jason are joined by Sara Chipps to discuss Jewelbots, Arduino and getting girls interested in STEM fields.

CppCast Episode 96: Jewelbots with Sara Chipps

by Rob Irving and Jason Turner

About the interviewee:

Sara Chipps is a JavaScript developer based in NYC. She has been working on Software and the Open Source Community since 2001. She’s been obsessed with hardware and part of Nodebots since 2012.

She is the CEO of Jewelbots, a company dedicated towards drastically changing the number of girls entering STEM fields using hardware.

She was formerly the CTO of Flat Iron School, a school dedicated to teaching people of all ages how to build software and launch careers as software developers.

In 2010 she cofounded Girl Develop It, a non-profit focused on helping more women become software developers. Girl Develop It is in 45 cities, and has taught over 17,000 women how to build software.

Post-Conditions on Self-Move—Eric Niebler

An issue we do not think often about:

Post-Conditions on Self-Move

by Eric Niebler

From the article:

TL;DR: In addition to the usual rule about move operations leaving the source object in a valid but unspecified state, we can add an additional guideline (not quite a rule, but follow it anyway):

Self-move assignment should “work” and leave the object in a valid but unspecified state.

Quick Q: Prevent user from derive from incorrect CRTP base

Quick A: Make it impossible to construct a class of the wrong type.

Recently on SO:

Prevent user from derive from incorrect CRTP base

1) make all constructors of Base private (if there are no constructors, add one)

2) declare Derived template parameter as friend of Base

template <class Derived>
class Base
{
private:

  Base(){}; // prevent undesirable inheritance making ctor private
  friend  Derived; // allow inheritance for Derived

public :

  void call ()
  {
      static_cast<Derived *>(this)->call_impl();
  }
};

After this it would be impossible to create any instances of the wrong inherited D2.

Quick Q: Conditionally acquire an std::mutex

Quick A: use a std::unique_lock with std::try_to_lock parameter in the constructor.

Recently on SO:

Conditionally acquire an std::mutex

It is actually unsafe to have a unique_lock accessible from multiple threads at the same time. I'm not familiar with the opencv portion of your question, so this answer is focused on the mutex/lock usage.

static std::mutex s_FAST_GPU_mutex;
{
   // Create a unique lock, attempting to acquire
   std::unique_lock<std::mutex> guard(s_FAST_GPU_mutex, std::try_to_lock);
   if (guard.owns_lock())
   {
       cv::gpu::FAST_GPU(/*params*/)(/*parameters*/);
       guard.unlock(); // Or just let it go out of scope later
   }
   else
   {
       cv::FAST(/*parameters*/);
   }
}

This attempts to acquire the lock, if it succeeds, uses FAST_GPU, and then releases the lock. If the lock was already acquired, then goes down the second branch, invoking FAST

Smelly std::pair and std::tuple—Arne Mertz

Do you use them badly?

Smelly std::pair and std::tuple

by Arne Mertz

From the article:

Depending on their use, std::pair and std::tuple can be code smells. That’s why we should be careful around these two.

Having a code smell is not a no-go, it’s more like a red flag. It’s one of those things that are not a problem themselves but rather a hint that there might be a less obvious problem hidden in the code.

Making things do stuff – Part 1—Glennan Carnie

C++ for embedded too!

Making things do stuff – Part 1

by Glennan Carnie

From the article:

C has long been the language of choice for smaller, microcontroller-based embedded systems; particularly for close-to-the-metal hardware manipulation.

C++ was originally conceived with a bias towards systems programming; performance and efficiency being key design highlights.  Traditionally, many of the advancements in compiler technology, optimisation, etc., had centred around generating code for PC-like platforms (Linux, Windows, etc).  In the last few years C++ compiler support for microcontroller targets has advanced dramatically, to the point where Modern C++ is a increasingly attractive language for embedded systems development...

Boost Your Productivity with Modern C++ - Now with C++17—Peter Gottschling

Repeating the last years' popular course, again being held in English and German:

Boost Your Productivity with Modern C++ - Now with C++17

by Peter Gottschling

About the training:

The course is designed for software developers who aim for excellent software characterized by intuitive interfaces and maximal performance. Our goal for this 4-day course is that you can afterwards program perceivably more productively. That your programs are usable more flexibly and nonetheless explore the hardware as efficiently as possible. That your software becomes clearer and simpler and thus more readable and more maintainable. For this purpose, we intensively use features of C++11, C++14, and for the first time C++17.

The trainer Peter Gottschling is the author of the advanced C++14 book "Discovering Modern C++",the Matrix Template Library 4, co-author of the Boost Graph Library and other scientific libraries. He is vice-chair of DIN's programming language group and was (the last) head of the German delegation in the ISO committee for C++ standardization.

The complete course description including the list of topics is available here.