CppDepend: A C++ Dependency Analyser

I evaluated the dependency analyser CppDepend on a real-life embedded application. My goal was to find all dependency cycles between classes in the application. I know that the application contains 50+ dependency cycles. CppDepend only found less than 10% of the cycles. Without rewriting the the source code, CppDepend would have found no cycles...

QCOMPARE with Custom Qt Types

When you write unit tests, you will have to compare the actual value and the expected value. A simplified example with QStrings would look like this. When you run this unit test, the QTest framework will print the actual value "abba" and the expected value "juhu". This is often enough to know what went...

Printing Custom Qt Types with qDebug()

When you define your own C++ types for a Qt application, you want to print their values with qDebug(), qWarning() or qCritical() eventually. The C++ compiler will complain with this error message: The error message tells you to write your own output operator for the QDebug stream and for QCanBusFrame. A custom C++ type...

Performance Gains Through C++11 Move Semantics

We explore when and how our code benefits most from equipping classes with move constructors and assignment operators. We analyse in detail, which constructors and assignment operators (move or copy) are called for C++98 and C++11 when we insert or emplace objects into containers, when we initialise containers and when we shuffle and sort...

Simplifying Loops with C++11 in Qt Ways

Recently, I looked through the code base of a medium-sized project to see how I could simplify handwritten for-loops by using C++11’s new range-based for and STL algorithms with lambda expressions. The results in short: Range-based for makes loops simpler, easier to understand and often faster. STL algorithms are often a bit harder to...

Scroll to top