Quick: When you design C++ APIs, when and how should you use pair and tuple? The answer is as simple as it is surprising: Never. Ever. When we design APIs, we naturally strive for qualities such as readability, ease-of-use, and discoverability. Some C++ types are enablers in this regard: std::optional, std::variant, std::string_view/gsl::string_span, and, of course, […]
C++ Get the RSS Feed
Content related to C++
KDAB talks at QtCon 2016
Hello! This is a small wrap-up fromQtCon, the biggest Qt event in Europe in 2016, that happened at the beginning of September. At QtCon the Qt community joined forces with the KDE, FSFE and VideoLAN communities, to create an exciting event in the spirit of open collaboration and participation amongst projects. During QtCon many KDAB […]
CppCon and Qt
KDAB was proud to sponsor CppCon this year, continuing to foster the Qt / C++ connection, talking about Qt and soaking up the immense range of C++ knowledge on display. KDAB’s Giuseppe D’Angelo gave a much appreciated, two-day Qt Widgets training as a pre-conference class, a condensed version of one of our scheduled Qt trainings, […]
Goodbye, Q_FOREACH A porting guide to C++11 ranged for-loops
Q_FOREACH (or the alternative form, foreach) will be deprecated soon, probably in Qt 5.9. Starting with Qt 5.7, you can use the QT_NO_FOREACH define to make sure that your code does not depend on Q_FOREACH. You may have wondered what all the fuss is about. Why is there a continuous stream of commits going to into Qt […]
Four Habit-Forming Tips to Faster C++
Are you a victim of premature pessimisation? Here’s a short definition from Herb Sutter: Premature pessimization is when you write code that is slower than it needs to be, usually by asking for unnecessary extra work, when equivalently complex code would be faster and should just naturally flow out of your fingers. Despite how amazing today’s […]
Very explicit operator bool Is the Safe Bool Idiom still useful in C++11 / C++14?
From time to time I scroll through Qt-related forums and mailing lists, and whenever possible I try to help fellow developers out. The other day a StackOverflow thread caught my attention: a developer was asking “What is the purpose of operator RestrictedBool in QScopedPointer?” Indeed, looking at QScopedPointer‘s implementation, one notices the strange RestrictedBool usage. […]
Faster than Fast String Search in Qt
Is your code burning a lot of cycles hunting for strings? Maybe you need to find the proper charset nestled in a chunk of HTML, or look for the dimensions in an XPM image file, or locate the email attachment boundaries in a block of MIME. If you string search a lot and performance is […]
QRegion will be iterable in Qt 5.8 - seamless integration with C++11 range-for
A novel solution to an old problem The QRegion class specifies a clip region for a painter. You can also query a QPaintEvent for the region() to limit the paint operations necessary in partial repaints. A region can be anything from a simple rectangle to a bitmap mask, but virtually all code that inspects a […]
KDAB contributions to Qt 5.6
Qt 5.6 has just been released! Packed with incredible new features, 5.6 is also the first long term support release of Qt: it will be supported for the next 3 years, giving developers a solid foundation for their current and upcoming projects. Once more, KDAB is confirmed to be the largest independent contributor to Qt, […]
KDAB at CppCon 2016
Washington, USA 2016-09-18 2016-09-23 Washington, September 18-23 Check it out http://cppcon.org/, get it in your diary. Why not contribute, folks? We’ll be there in more ways than one, including this 2 day training Programming with Qt Widgets. We’ll be bringing you updates as the year progresses.