September 2017

Static libs do not modular make -- Thomas Young

An article about static libraries, the benefits (or non-benefits) of splitting your project into static libraries, and the knock-on effects this can have on project dependencies.

Static libs do not modular make

by Thomas Young

From the article:

A cautionary tale about statically-linked libraries, as generated by C/C++ build tools.

As a project accumulates features, and complexity, it gets harder to understand exactly what's going on, and to find your way around the source code. You need to find some way to organise the code and try and keep things manageable.

A common idea, in this situation, is to group some source files together to split out as a static library.

I'm going to argue that this actually does very little, in itself, to increase modularity, can have the effect of significantly increasing dependencies, and is maybe not such a good idea, after all.

CppCast Episode 119: C# and IL2CPP with Josh Peterson

Episode 119 of CppCast the only podcast for C++ developers by C++ developers. In this episode Rob and Jason are joined by Josh Peterson from Unity 3D to talk about C# and some of the similarities and differences between the Managed language and C++, he also talks about his work at Unity 3D on IL2CPP.

CppCast Episode 119: C# and IL2CPP with Josh Peterson

by Rob Irving and Jason Turner

About the interviewee:

Josh is a programmer working at Unity Technologies, where he focuses on integration and development of scripting runtimes for the Unity 3D game engine. He enjoys learning about CPU architectures and assembly language, including the recent development of an MOS 6510 emulator in C#. In his free time, he coaches a number of youth soccer teams and reads philosophy and theology.

Quick Q: What are template deduction guides in C++17?

Quick A: A solution for automatic template resolution on constructors.

Recently on SO:

What are template deduction guides in C++17?

Template deduction guides are patterns associated with a template class that tell the compiler how to translate a set of parameter (and their types) into template arguments.

The simplest example is that of std::vector and its constructor that takes an iterator pair.

template<typename Iterator>
void func(Iterator first, Iterator last)
  vector v(first, last);

The compiler needs to figure out what vector<T>'s T type will be. We know what the answer is; T should be typename std::iterator_traits<Iterator>::value_type. But how do we tell the compiler without having to type vector<typename std::iterator_traits<Iterator>::value_type>?

You use a deduction guide:

template<typename Iterator> vector(Iterator b, Iterator e) -> vector<typename std::iterator_traits<Iterator>::value_type>;

This tells the compiler that, when you call a vector constructor matching that pattern, it will deduce the vector specialization using the code on the right of ->.

You need guides when the deduction of the type from the arguments is not based on the type of one of those arguments. Initializing a vector from an initializer_list explicitly uses the vector's T, so it doesn't need a guide.

The left side doesn't necessarily specify a constructor. The way it works is that, if you use template constructor deduction on a type, it matches the arguments you pass against all deduction guides (actual constructors provide implicit guides). If there is a match, it uses that to determine which template arguments to provide to the type. But overload resolution to determine which constructor to call happens after that.

This also means that you can use guides with aggregates and aggregate initialization:

template<typename T>
struct Thingy
  T t;

Thingy(const char *) -> Thingy<std::string>;

Thingy thing{"A String"}; //thing.t is a `std::string`.

So deduction guides are only used to figure out the type being initialized. The actual process of initialization works exactly as it did before, once that determination has been made.

Detection Idiom - A Stopgap for Concepts--Simon Brand

Concepts are not yet here, but there are solutions.

Detection Idiom - A Stopgap for Concepts

by Simon Brand

From the article:

Concepts is a proposed C++ feature which allows succinct, expressive, and powerful constraining of templates. They have been threatening to get in to C++ for a long time now, with the first proposal being rejected for C++11. They were finally merged in to C++20 a few months ago, which means we need to hold on for another few years before they’re in the official standard rather than a Technical Specification. In the mean time, there have been various attempts to implement parts of concepts as a library so that we can have access to some of the power of Concepts without waiting for the new standard. The detection idiom – designed by Walter Brown and part of the Library Fundamentals 2 Technical Specification – is one such solution. This post will outline the utility of it, and show the techniques which underlie its implementation.

Volunteer at Meeting C++ 2017

For the first time ever, you can participate in Meeting C++ as a volunteer, just like you could do with CppCon!

Volunteering at Meeting C++ 2017

by Jens Weller

From the article:

Something new, which didn't exist in the last 5 editions of the Meeting C++ conference. You are now able to become a volunteer at Meeting C++ 2017, like you can and always could do for CppCon.

Historically the staff for Meeting C++ first was from my own C++ User Group...

What's new in clang-format 5

A good way to simplify your life:

What's new in clang-format 5

by Benoît Blanchon

From the article:

Clang 5 was released last week.
It's a good opportunity to talk about a not-enough-known tool: Clang-format.

Clang-format is part of the Clang project but can be used without the Clang compiler. It's an independent executable.

Clang-format is a code linter for C++. It takes a non-formatted code as input and produces a well-formatted code as output. The result is instantaneous.

Just::Thread Pro v2.5.0 released with coroutines support--Anthony Williams

A new version is out.

Just::Thread Pro v2.5.0 released with coroutines support

by Anthony Williams

From the article:

I am pleased to announce that Just::Thread Pro v2.5.0 has been released. This adds support for gcc 7, clang 4.0 and clang 5.0, but the big change with this version is the support for coroutines with Microsoft Visual Studio 2017, and clang 5.0 on ubuntu when used with libc++ 5.0.

CppCast Episode 118: FluentC++ with Jonathan Boccara

Episode 118 of CppCast the only podcast for C++ developers by C++ developers. In this episode Rob and Jason are joined by Jonathan Boccara to talk about the FluentC++ blog and the benefit of doing daily C++ talks at your office.

CppCast Episode 118: FluentC++ with Jonathan Boccara

by Rob Irving and Jason Turner

About the interviewee:

Jonathan Boccara is a passionate C++ developer working for Murex on a large codebase of financial software. His interests revolve around making code expressive. He regularly blogs on Fluent C++, where he explores how to use the C++ language to write expressive code, make existing code clearer, and also about how to keep your spirits up when facing unclear code. Jonathan loves writing, making videos, reading programming books, hanging out at conferences, meeting people, learning new languages and making trainings and presentations.

C++ for Embedded Developers, 25-29 September, UK

Join us to gain practical experience of writing C++ for real-time and embedded systems in Swindon, UK.

C++ for Embedded Developers

About the course:

This course is designed for:

  • real-time engineers embarking on a project using C++ for the first time
  • developers looking to move from C to C++ (as it will clearly demonstrate both the strengths and weaknesses of C++ vs. C)

Course overview

The course introduces the C++ language for use on real-time and embedded applications. It highlights areas of concern for real-time and embedded development. The focus is on developing core object-oriented programming skills and understanding of how to build effective, maintainable and efficient C++ programs.

Attendees perform hands-on embedded programming, on target hardware, during course practicals. Approximately 50% of the course is given over to practical work.

Course objectives

  • To provide a solid understanding of the essentials of the C++ programming language.
  • To give you practical experience of writing C++ for real-time and embedded systems.
  • To give you the confidence to apply these new concepts to your next real-time project.

Delegates will learn

  • The core C++ syntax and semantics
  • How to access hardware in the language
  • How to program interrupt handlers in C++
  • About memory and performance issues associated with C++
  • How real time operating systems (RTOS) affect the use of the language