News

When an Empty Destructor is Required -- Andreas Fertig

me.pngIn my previous post, "Why you shouldn't provide an empty destructor," we discussed the importance of not providing an empty destructor in most cases. However, in this post, we'll explore a rare exception to this rule that arises when using the PImpl idiom to hide implementation details, specifically in situations where the unique_ptr encounters issues with incomplete types. Let's delve into this exception and learn when it's necessary to provide an empty destructor.

When an Empty Destructor is Required

by Andreas Fertig

From the article:

As you probably know from life, not only programming. There is no rule without an exception. Let's talk about the one case that requires an empty destructor (yes, I know it sounds silly). Suppose you have the following code:

In file included from <source>:2:
In file included from /opt/compiler-explorer/gcc-12.2.0/lib/gcc/x86_64-linux-gnu/12.2.0/../../../../include/c++/12.2.0/memory:76:
/opt/compiler-explorer/gcc-12.2.0/lib/gcc/x86_64-linux-gnu/12.2.0/../../../../include/c++/12.2.0/bits/unique_ptr.h:93:16: error: invalid application of 'sizeof' to an incomplete type 'Orange'
        static_assert(sizeof(_Tp)>0,
                      ^~~~~~~~~~~
/opt/compiler-explorer/gcc-12.2.0/lib/gcc/x86_64-linux-gnu/12.2.0/../../../../include/c++/12.2.0/bits/unique_ptr.h:396:4: note: in instantiation of member function 'std::default_delete<Orange>::operator()' requested here
          get_deleter()(std::move(__ptr));
          ^
<source>:4:7: note: in instantiation of member function 'std::unique_ptr<Orange>::~unique_ptr' requested here
class Apple
      ^
<source>:6:27: note: forward declaration of 'Orange'
    std::unique_ptr<class Orange> mOrange{};
                          ^
1 error generated.
Compiler returned: 1
 
Essentially, this message tells you that the std::unique_ptr cannot instantiate the required destructor for itself typed with Orange. The simple reason is that, at this point, Orange has no visible destructor. Which is the entire point of the PImpl idiom. What now?

Releasing the keynotes of Meeting C++ 2023

Highlighting the current video releases for Meeting C++ 2023: the keynotes

With this year Meeting C++ had a unique set of keynotes, covering 6 impossible problems for software devs with the opening keynote by Kevlin Henney, followed by great wisdom about how open communities thrive by Lydia Pintscher. The closing keynote by Ivan Čukić was an impressive medley composing various idioms with Prog(ressive) C++.

All these keynotes are worth watching, a great contribution to our knowledge base as a community. Thanks to Kevlin Henney, Lydia Pintscher and Ivan Čukić for preparing these great presentations!

Boost 1.84.0 has been released

space.pngspace.pnggetboost.pngRelease 1.84.0 of the Boost C++ Libraries is now available.

These open-source libraries work well with the C++ Standard Library, and are usable across a broad spectrum of applications. The Boost license encourages both commercial and non-commercial use.

Release 1.84.0 contains two new libraries and numerous enhancements and bug fixes for existing libraries.

New Libraries

  • Cobalt: Basic algorithms and types for C++20 coroutines, from Klemens Morgenstern.
  • Redis: Redis async client library built on top of Boost.Asio, from Marcelo Zimbres Silva.

Here are some useful links for 1.84.0.


Marshall Clow and Glen Fernandes managed this release - we very much appreciate their continued hard work!

C++20, Spans, Threads and Fun -- Bartlomiej Filipek

C++20_Spans_Threads_and_Fun.pngIn this post, we’ll have fun using C++20’s spans to process data on multiple threads. What’s more, we’ll be equipped with the latest concurrency features from C++20.

C++20, Spans, Threads and Fun

by Bartlomiej Filipek

From the article:

Our task is relatively simple but can be extended to various multi-phase computations.

We need to initialize a container with numbers, filter them, then build a histogram.

Here’s the overview of the process:

CLion Nova Explodes onto the C and C++ Development Scene -- Anastasia Kazakova

clionnova.pngWe’re announcing a free early preview of CLion, which uses the ReSharper C++/Rider C++ language engine instead of the CLion "legacy" engine. The Preview build is available via our dedicated Toolbox App feed. At some point in 2024, depending on the results of the feedback collected, CLion Nova will be merged into CLion. Until then, the Preview build will be free to use and can be installed in parallel with your usual CLion (Classic) installation.

CLion Nova Explodes onto the C and C++ Development Scene

by Anastasia Kazakova

From the article:

The first C++ engine by JetBrains was designed for AppCode, our IDE for iOS and macOS developers. It was part of the IntelliJ Platform, initially written in Java and later also in Kotlin. The approach and the architecture of the engine serve many languages in IntelliJ-based IDEs well; however, this design turned out not to be the best fit for the C++ language specifically.

To more quickly align with the evolution of C++ and to separate the engine and IDE processes, a clangd-based engine was later added to CLion. Built on our custom branch of clangd, this engine detects any warnings and errors, shows them in the editor, and suggests quick-fixes, as well as performing highlighting, completion, and certain navigation actions. It’s also used for things like data flow analysis and MISRA checks. Meanwhile, CLion’s “legacy” engine is responsible for other code insight features like refactorings. You can see a detailed “list of responsibilities” in our CLion documentation.