Hello C++ developers, this week we have five more professional and intermediate-level topics in modern C++. Modern C++ has many features to aid multi-thread programming that allow your applications to be faster and more responsive. Since the C++11 standard, the Concurrency Support Library includes built-in support for threads (std::thread
) with atomic operations (std::atomic
). In the first two post picks today, we explain how to allow atomics use in C++ signal handlers, plus we teach how to use atomic_flag
. In another post, we explain how to use propagating exceptions. We also teach what the volatile
keyword is and what it does. In the last post pick, we explain the concept of weak compare and exchange in modern C++.
RAD Studio’s C++ Builder, Delphi, and their free community editions C++ Builder CE, and Delphi CE are a real force for modern application development.
Our educational LearnCPlusPlus.org site has a whole bunch of new and unique posts with examples suitable for everyone from beginners to professionals alike. It is growing well thanks to you, and we have many new readers, thanks to your support! The site features a plethora of posts that are great for learning the features of modern C++ compilers with very simple explanations and examples.
Table of Contents
Where I can I learn C++ and test these examples with a free C++ compiler?
If you don’t know anything about C++ or the C++ Builder IDE, don’t worry, we have a lot of great examples on the LearnCPlusPlus.org website and they’re all completely free. Just visit this site and copy and paste any examples there into a new Console, VCL, or FMX project, depending on the type of post. We keep adding more C and C++ posts with sample code. In today’s round-up of recent posts on LearnCPlusPlus.org, we have new articles with very simple examples that can be used with:
- The free version of C++ Builder 11 CE Community Edition
- or a professional version of C++ Builder
- or free BCC32C C++ Compiler and BCC32X C++ Compiler
- or the free Dev-C++
Read the FAQ notes on the CE license and then simply fill out the form to download C++ Builder 11 CE.
How to use modern C++ with C++ Builder?
C++11 allows the use of atomics in signal handlers, and with the advent of C++ 17 the signal handler feature was again improved. The std::atomic_flag
is an atomic boolean
type that is guaranteed to be lock-free and can be used in signal handlers. Moreover, the <csignal>
header in C++ has an integer type std::sig_atomic_t
that can be accessed as an atomic entity even in the presence of asynchronous interrupts made by signals. In our first post ğ,cl, we explain how to use atomic_flag in C++.
In C++17, in addition to the std::atomic_flag
in <atomics>
, the <csignal>
header has an integer type std::sig_atomic_t
that can be accessed as an atomic entity even in the presence of asynchronous interrupts made by signals. In this next post, we explain how to use atomic_flag
in C++.
The C++11 standard offers the possibility of moving an exception from one thread to another. This type of movement is called propagating exceptions, exception propagation; also known as rethrow exception in multi-threading. To do that, some modifications have been made to the <exception>
header in C++ and there is a nullable pointer-like type std::exception_ptr
. In the next post, we explain std::exception_ptr
and how to use the rethrow exception method in modern C++.
C++ is very strong in every aspect of modern programming. Volatile types are used with the volatile
keyword. It is a lesser known type qualifier that is important to read types or objects whose value can be modified at any time. The volatile keyword is useful in memory-mapped applications, generally these are from a hardware device, from a sensor, from an input device, or data from on an IoT. For example, an application reading dynamic data from the registers of a medical robot and decides what to do with that robot arm. In the next post, we will explain the volatile keyword in C++ and how can we use volatile type specifier.
Since the C++11 standard, the Concurrency Support Library includes built-in support for threads (std::thread
) with atomic operations (std::atomic
). C++11 provides both weak and strong compare-and-exchange operations in multi-threading applications. Since C++11, weak compare and exchange are used in modern C++ standards such as C++14, C++17, C++20, and in other new standards. In the last post, we explain weak compare and exchange with simple examples.
How to learn modern C++ for free using C++ Builder?
LearnCPlusPlus.org has been producing full of educational daily articles about C and modern C++ that can be used with C++ Builder, C++ Builder CE, Dev-C++, BCC Compiler and some other compilers such as the GCC compiler. Here are our post picks for today.
We like to hear your feedback. You motivate us so much with your likes and comments on social media (find us on Facebook, LinkedIn, Reddit, Twitter / X and all over) and here on the blogs too. Thank you for your valuable comments and questions. All of them help improve the quality of our future posts and new code in these posts.
We have a lot of unique posts waiting to come. We keep adding new topics every week about C++ in general and specific topics for C++ Builder, Dev-C++, and for the other C++ compilers. Please keep following our LearnCPlusPlus.org website for the latest posts and updates. Feel free to comment and share with your colleagues, students, members – knowledge is power, and knowledge shared is empowering.
Do you want to know some more news about C++ Builder 12?
David Millington, Developer and Product Manager of C++ Builder just released a new video about “Behind the Build: RAD Studio and C++Builder 12.0”. According to David Millington’s post, C++ Builder is aiming to include some amazing features and a lot of performance improvements in operations. C++Builder 12 plans to bring some massive improvements, the enhanced Clang toolchain and Visual Assist integration, substantial improvements across RTL, STL, debugging, and more. Here is the full presentation,
Here are a few of my notes,
- Comes with a special CLANG 15 Win64 compiler
– Win64 is a primary OS
– New Clang means support for C++20 and a lot of C++23 features
– Important to have more compatible standards and amazingly faster
– In memory allocation operations, it is 6 to 14% faster than the current CLANG Win64 compiler in C++ Builder
– In unordered map hashing, STL performance is 60 to 70% faster than the current CLANG Win64, and 40 to 70% faster than the current CLANG Win32 in C++ Builder - Comes with a new Visual Assist in the IDE
– Fast code completion
– Navigation and refactoring
– and more - Debugging will use PDB outputs within the IDE
- VCL and FMX have not adopted yet, this may take time
- This presentation is an early preview, unfiltered and incomplete, they do not promise these features to be in 12.0
Please note that all comments and statements about potential new features are subject to change and should not be relied on until the GA release of a product is available.
C++ Builder is the easiest and fastest C and C++ IDE for building simple or professional applications on the Windows, MacOS, iOS & Android operating systems. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs.
There is a free C++ Builder Community Edition for students, beginners, and startups; it can be downloaded from here. For professional developers, there are Professional, Architect, or Enterprise version.