New updates of CppHints.com, service of recommendations on C++ programming from PVS-Studio team

New updates of C++Hints, service of recommendations on C++ programming

Changes in CppHints.com

by PVS-Studio Team

We got a lot of positive feedback from our readers and continue developing the C++Hints project. We have also answered two requests, that we saw quite often in the letters:

By this moment we have published the following articles:

An introduction to C++'s SFINAE concept -- Jean Guegant

Jean Guegant describes in a very detailed way different implementation stategies of compile-time introspection of a class member for C++98, C++11 and C++14.

An introduction to C++'s SFINAE concept: compile-time introspection of a class member

by Jean Guegant

From the article:

As a C++ enthusiast, I usually follow the annual C++ conference cppconf or at least try to keep myself up-to-date with the major events that happen there. One way to catch up, if you can't afford a plane ticket or the ticket, is to follow the youtube channel dedicated to this conference. This year, I was impressed by Louis Dionne talk entitled "C++ Metaprogramming: A Paradigm Shift". One feature called is_valid that can be found in Louis's Boost.Hana library particulary caught my attention. This genious is_valid function heavily rely on an even more "magic" C++ programming technique coined with the term SFINAE discovered at the end of the previous century. If this acronym doesn't speak to you, don't be scared, we are going to dive straight in the subject.

Random Acts of Optimization --Tony Albrecht

Discussion regarding systematic approach to go about optimization of logic.

Random Acts of Optimization

by Tony Albrecht

From the article:

The three stages mentioned here, while seemingly obvious, are all too often overlooked when programmers seek to optimize. Just to reiterate:

    1. Identification: profile the application and identify the worst performing parts.
    2. Comprehension: understand what the code is trying to achieve and why it is slow.
    3. Iteration: change the code based on step 2 and then re-profile. Repeat until fast enough.

The solution above is not the fastest possible version, but it is a step in the right direction—the safest path to performance gains is via iterative improvements.

Using Variadic Templates cleanly--Florian Weber

Variadics are even more easy to use than we tought:

Using Variadic Templates cleanly

by Florian Weber

From the article:

When one comes across examples for variadic templates, almost always recursion is used to achieve almost everything, for example like this:

// We are lucky: the author correctly used zero
// arguments instead of one as the base-case,
// thereby avoiding code-duplication:
inline void print_to_stream(std::ostream&) {}

template<typename Head, typename...Tail>
void print_to_stream(std::ostream& stream, const Head& h, const Tail&... t) {
  stream << h;
  print_to_stream(stream, t...);
}

In this article we will see what better alternatives for this rather clumsy hack exist and see how we can write a better version with less code...

Trip report: C++ standards meeting in Kona, October 2015 -- Stephan T. Lavavej

The fall ISO C++ standards meeting concluded less than 24 hours ago, and our own STL (the person, not the library) has posted the first trip report to Reddit. It was a very successful meeting with considerable progress.

C++17 Progress Update! (Oct 2015)

by Stephan T. Lavavej (aka STL)

Note that this report is focused on an overview of what reached full committee approval, with an emphasis on library features. Important milestones were also achieved to progress other major topics, including modules, contracts, and variant that we hope will reach formal full committee approval at the next meeting or two, and these topics will no doubt be covered in other people's trip reports and commentaries as well.

C++ day in Spain: using std::cpp 2015

The Spanish-language C++ event using std::cpp 2015 will gather C++ Spanish comunity in a full one day free event.

using std::cpp 2015

November 18, 2015

University Carlos III of Madrid in Leganés

For the 3rd year, University Carlos III of Madrid, hosts using std::cpp, an event for C++ software developers held in Spain. Past editions of using std::cpp have had participations around 200 people each year where 75% were professional software developers and the other 25% where academics and students. The event offers a godd opportunity for the Spanish C++ comunity to gather together and exchange experiences about the language as well as to provide udpdated information about the language.

Some program highlights:

  • Concepts Lite (Manu Sánchez, By Tech)
  • Contract based programming in C++ (J. Daniel García, University Carlos III)

You may access to videos and slides from previous years:

For more information you may contact J. Daniel Garcia.

More than you need--Andrzej KrzemieĊ„ski

Some thoughts about what the standard provides by default:

More than you need

by Andrzej Krzemieński

From the article:

The classes you design can do more (in terms of allowed operations) than what you could figure out from just looking at their member function declarations. The C++ Standard defines a number of cases where certain expressions involving your type are valid, even though there are no corresponding member function declarations. Sometimes this is just what you need; but sometimes the additional operations you never asked for can have grave negative impact on your program correctness...