C++ annotated: Sep – Dec 2016
Today we are happy to share our next compilation of C++ news with you.
C++ Annotated: September – December 2016
In this edition:
These months were full of great conferences – CppCon, ADC (former JUCE), LLVM US Meetup, Meeting C++, and some more local group meetups and smaller conferences. They are over now, but playlists with talk recordings are available for those who missed an event or just want to dive into it once again.
First came CppCon 2016. The biggest event in the C++ world brought us 7,653 minutes of video recorded this year for 111 presentations and 31 lightning talks: from philosophical keynotes by Bjarne Stroustrup titled The Evolution of C++ Past, Present and Future to the state of C++ Core Guidelines in Neil MacIntosh’s The Guideline Support Library: One Year Later and many more. Also, don’t miss great advice from Jon Kalb: “Don’t use unsigned for quantities” from his lightning talk, unsigned: A Guideline for Better Code.
ADC (former JUCE) conference gathered Audio Developers from all over the world, and brought to light lots of topics around C++ modern language features, performance optimization and embedded development. Keynotes varied from the fantastic Dan Saks speaking about modern C++ instead of pure C in embedded development, to the legendary Roger Linn with his LinnStrument on stage playing demos.
LLVM US Meetup
The yearly LLVM US Developers meetup took place in early November in California. Among the recordings from the event one can find a highly interesting talk by Gor Nishanov about LLVM Coroutines, the story of LLVM and Clang transition to CMake by Chris Bieneman, and many more. The JetBrains C++ team also joined the event with a small lightning talk by Ilya Biryukov on how the compiler frontend is different from what an IDE needs, trying to explain why our C++ tools do not rely on Clang as a code parser.
Meeting C++, the key European C++ event, was as usual held at the Andels hotel in Berlin this past November. The organizers brought together many famous names from the C++ community, including Bjarne Stroustrup, James McNellis, Timur Doumler, Jon Kalb, Michael Caisse, Arne Mertz, Odin Holmes, and many others, and offered an impressive program. Besides, it’s worth mentioning a quiz from Diego Rodriguez-Losada, the author of Conan. Interested in challenging yourself? Check 10 tricky code snippets from Meeting C++ in the Conan blog.
The extensive worldwide collection of C++ focused user groups continues to grow, with at least two new groups starting up this quarter.
In Russia, the St. Petersburg C++ User Group started in October and has been meeting monthly since. Meanwhile, in the UK, C++::London started in December and also plans to continue monthly, with the January meet-up already scheduled. Both groups have been well attended, so if you’re in or near either of those cities do join up.
Catching bugs at compile time
Andrzej’s C++ blog introduced a couple of blog posts on catching this non-obvious bug at compile time. The sample is simple and was generated by selecting an inappropriate completion suggestion. Still the discussion is interesting as an overview of possible workarounds in order to catch such issues with the help of the compiler. The author tried invoking a memory access violation (by providing another String implementation that assumes it will never be given a Null pointer), then comes to __builtin_unreachable()– and preconditions-based implementation samples. Another solution discussed in the blog is const usages.
Understanding fold expressions
Reducing a parameter pack over a binary operator with the fold expression is a new ability provided by the upcoming C++17. In his blog, Sumant Tambe tries unary left fold for operators and shows some interesting observations from his test, which shows some differences in how Clang and GCC handle the feature. There is also a valuable discussion of corner cases (like empty or single parameter packs).
Modern C++ features with Arne Mertz
The Simplify C++ blog by Arne Mertz was as usual full of interesting posts on various topics. Two attract the most attention: first, a general introduction to user-defined literals, with samples and use case description, and string literals (C++14) case in the very end.
Second, a series about variadic templates, providing full instruction on how to build and expand the parameter pack in templates. Empty packs, sizeof… operator and some additional tricks were also discussed.
If you want to write something similar to “42.times do …” in C++, the answer by Dmitry Ledentsov is user-defined literals. Jon Kalb, however, attempted to play with it with more traditional syntax, so if you are not afraid of SFINAE, variadic templates, perfect forwarding, etc., check his blog post. The core idea among others is to make the code general, working for functions, function pointers, function objects and lambdas, with arbitrary values to be used as parameters to the callable.
Error handling strategy
Jonathan Müller in his foonathan::blog() published of series of posts on error handling. He discusses user errors, system errors and programming errors, checking whether it’s worth using recoverable or unrecoverable error handling strategy in each of the cases. The series also includes tips on customizable and modular assert implementations, as well as a discussion of C++ type system flexibility.
Next generation Doxygen for C++
Doxygen is a well-known format (de facto standard in many cases) for generating documentation from the annotated sources in various programming languages, including C++. Standardese (by Jonathan Müller) is a new library and a tool for getting documentation for C++ code. Its main goal is to fit C++ code bases more accurately, formatting the docs in a similar way to the standards themselves. It also aims to handle C++ language features in a smarter way (like SFINAE), provide balanced type information (not overwhelmed with various aliases and unnecessary return types), document private members, and more.
The Internet of Things, embedded development, and the future of C++
Qt blog published a research article looking into potential IoT market growth. Some interesting trends are mentioned. The number of connected devices is estimated to reach 20.7 billion by 2020, and 95% of today’s embedded systems are created with C/C++. Given that the number of C++ developers is growing at a very modest pace, how do we produce the software for that many devices? One of the answers suggested by the article is to enable C++ developers to be more productive. What better area for tools to make a difference! Check the blog post for the details.
Phil Nash & C++ team in JetBrains
In September Phil Nash, a well-known speaker and an author of the Catch framework, signed up as a Developer Advocate for C++ tools at JetBrains (also covering Objective-C and Swift). In his interview he shares his story and provides his vision on his duties as a developer advocate. There is also another episode of CppCast with Phil, focusing on his role in the community, Catch 2 and recent releases of JetBrains C++ tools.
Functional C++ for Fun and Profit
Phil Nash has a small tour with his “Functional C++ for Fun and Profit” in November and December, which includes many European User Groups meetups and the Meeting C++ conference. If you missed the discussion of the functional approach to software design and how it applies to modern C++, catch up with the recording.
Online compilers and not only
Jens Wellers overviewed the web resources that allow you to compile a piece of C++ code right in the browser and are collaborative in the sense that multiple people are able to edit the code interactively. It turned out to be a useful list, with not so many options supporting the latest C++ standard.
There is also a nice resource providing a long list of basic C++ code samples. Each code sample comes with a description and a comment section for discussion and questions.
CMake reference by LLVM
LLVM 3.9 dropped the autoconf build system in favor of CMake. To make the life of LLVM contributors a bit easier and clearer, the rich document on CMake was introduced. Not being a full tutorial or every feature reference, but more like a general introduction to the basic commands, principles and solutions used across the LLVM project, it can be helpful to both LLVM contributors and those who are starting to learn CMake.
CMake support in Visual Studio
Visual Studio 2017 will be delivered with two new options for those who are not using Visual Studio projects – open project from folder and CMake support. If you are planning to start/open a CMake project in VS, check their blog post, in which Marian Luparu gives a quick overview of the CMake features in Visual Studio. It includes opening CMake-based projects and working with them to benefit from all the intelligent features VS provides as an IDE. It also provides an ability to edit CMake files, update CMake Cache and tune CMake configurations. And of course, users can build and debug such solutions in Visual Studio 2017.
Understanding the performance and drawbacks of standard functions is essential in order to use them effectively. Daniel Lemire in his blog post runs a comparison of the standard function for date shuffling (std::shuffle) and the standard Fisher-Yates shuffle algorithm. Check the blog post to see who won!
Is code faster than data?
Another performance test was run to check whether custom code for compile time data structure lookup functionality was faster than data. To be exact, the author compared the performance of the switch statement to that of a simple array type. The test was compiled within Visual Studio 2015 for 6 various data containers, running sequential, shuffle and sparse sums. The switch function turned out to be much, much slower than other options! Read the blog post for an explanation of the results.
Can a C++ package manager be written in C++?
Conan blog starts a discussion, sharing arguments for Python (for both UI language for packages definition and package manager core), and some philosophical fallacy around C++ package manager written in C++. Do you agree? Or do you think it’s more practical to use the same language (i.e. C++) than a completely new Python toolset?
CLion 2016.3, another major update of JetBrains’ cross-platform IDE for C and C++ development, brought lots of key improvements. User-defined literals are supported including Rename refactoring, C++14 digit separator support, C11 keywords completion, and overload resolution improvements. Code analysis fixes from the language side include: ability to change CMake generation directory, ability to build only those CMake configurations that were added in settings, ability to open project from existing directory, and more. From the project model side code analysis fixes include project templates, remote debug on Windows, semantic highlighting, and more.
ReSharper C++ 2016.3
The ReSharper family received an update too, including ReSharper C++ 2016.3. With new refactorings (Introduce/Inline Typedef) to clean-up code, postfix completion to speed up code typing, Catch test framework support and dozens of smaller improvements, this Visual Studio extension is even more powerful and user-friendly.
Qt Creator 4.2
Qt Creator 4.2 was released with improved CMake support, cleaned projects mode UI, an ability to get local diff, an option to exclude files from indexing, and Clang code models enhancements.
PVS-Studio for Linux
PVS-Studio analyzer was released for Linux. To prove it was worth the effort, they put the most famous projects under investigation and re-checked the Linux kernel. This helped catch issues with string operations having the wrong string length, incorrect order of arguments, precedence problems, and others.
The C++ Team
Subscribe to Blog updates
Thanks, we've got you!
ReSharper C++ 2023.2: Safe Delete Refactoring, AI Assistant, New C++23 and C++20 Features
New release brings the Safe Delete refactoring, support for several new C++20 and C++23 features, ReSharper’s AI Assistant, and more.
ReSharper C++ 2023.1: Call Tracking, Macro Expansion Preview, and Support for C++23 Features
ReSharper C++ 2023.1 brings updates for C++20 and C++23 features, and also introduces Call tracking for incoming calls and macro substitution previews in tooltips and Quick Documentation popups.
ReSharper C++ 2022.3: C++20 Modules and Clang-Format Integration
ReSharper C++ 2022.3 introduces experimental support for C++20 modules and provides seamless integration with clang-format.