As of the CopperSpice 2.0 release our libraries require a compiler which supports the C++20 standard. We have made this transition to use new functionality available in the core C++ language. This change requires a modification to the build files for projects which link with CopperSpice.
For convenience, we have modified the zip file for examples 1 through 47. Line 35 of the CMakeLists.txt file was changed as shown below.
set(CMAKE_CXX_STANDARD 20)
New in C++20
Transitioning to C++20 allowed the project to use concepts, enable new functionality in std::chrono, improve CopperSpice unit tests, report additional type conversion warnings, and a slew of other things.
There were two changes in CopperSpice which had the most effect and improved the code base. These are described below.
** Spaceship
Three-way comparison operator is also known as the “spaceship operator” because of the shape of the operator, which is <=>. This operator is used to compare two values and determine their equality or if one is less than or greater than the other value.
This new operator simplifies implementing comparison operations and usually results in more efficient code.
** char8_t
A string literal is a sequence of characters enclosed in double quotes. For example, “Hello CopperSpice”. String literals are commonly used to initialize the value of an std::string or a QString.
C++11 added a UTF-16 string literal which has the data type of char16_t and UTF-32 string literals with a data type of char32_t. The standard committee forgot to add a new data type for UTF-8 string literals. This was corrected in C++20.
Prior to C++20 the data type of a UTF-8 string literal was char. With the release of C++20 a UTF-8 string literal finally has a unique data type of char8_t.