From 448d26da3004719cee23451ea3237a299722682e Mon Sep 17 00:00:00 2001 From: Matthias Wittgen Date: Mon, 28 Apr 2025 14:06:12 -0700 Subject: [PATCH 1/2] Update for C++20 --- cpp/style.rst | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cpp/style.rst b/cpp/style.rst index 88ea6426..b2d7cbc4 100644 --- a/cpp/style.rst +++ b/cpp/style.rst @@ -84,24 +84,25 @@ These tasks are made much simpler if the code is easily readable and well-docume .. _style-guide-cpp-2-2: -2-2. We are writing C++17 +2-2. We are writing C++20 ------------------------- -We follow the official: International Standard ISO/IEC 14882:2017(E) – Programming Language C++, without any compiler specific extensions. +We follow the official: International Standard ISO/IEC 14882:2024(E) – Programming Language C++, without any compiler specific extensions. .. note:: We use compilers provided by a specific :ref:`Conda environment ` executing on a defined :ref:`baseline platform `. - This environment provides complete support for C++17, but --- in the case of compiler bugs --- the allowed set of C++17 features is those which can be shown to work properly in this reference environment. + This environment provides complete support for C++20, but the allowed set of C++20 features is limited to those that can be shown to work properly in this reference environment. In practice, we further restrict the feature set to those that also work on our commonly-tested platforms. -The C++17 standard adds a number of useful features such as nested namespace definitions, structured binding declarations, initializers in ``if`` and ``switch`` statements, class template argument deduction, ``std::optional``, ``std::any``, ``std::filesystem``, and ``std::variant``. -A parallel algorithms library has also been added, although use of this in Science Pipelines code should be vetted, as we typically use one-core-per-process parallelization. -``std::auto_ptr`` has been removed and should typically be replaced by ``std::unique_ptr``. +The C++20 standard adds a number of useful features such as struct initialization with named fields, ``consteval`` and ``constinit``, improvements to ``constexpr``, the three-way comparison operator (``<=>``), and improved ``lambdas``. +It also includes enhancements of the standard library including ``ranges``, definition of mathematical constants in ````, ``std::format``, ``std::span``, improved calendar and timezone support in ``chrono``. -When using C++17 features, be careful about readability for developers familiar only with C++14. +The use of ``modules`` is discouraged. The use of ``concepts`` and ``coroutines`` should be evaluated carefully. -If you find that any Style Guide rules conflict with C++17 best practices, such as those in the `C++ Core Guidelines`_, please propose updates. +When using C++20 features, be careful about readability for developers familiar only with C++14. + +If you find that any Style Guide rules conflict with C++20 best practices, such as those in the `C++ Core Guidelines`_, please propose updates. .. _C++ Core Guidelines: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md From 5797247f0f4fa4d5fd34d0dd8dbeb222e6c20033 Mon Sep 17 00:00:00 2001 From: Matthias Wittgen Date: Mon, 28 Apr 2025 16:19:38 -0700 Subject: [PATCH 2/2] Update for C++20 --- cpp/style.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/style.rst b/cpp/style.rst index b2d7cbc4..639beb9e 100644 --- a/cpp/style.rst +++ b/cpp/style.rst @@ -100,7 +100,7 @@ It also includes enhancements of the standard library including ``ranges``, defi The use of ``modules`` is discouraged. The use of ``concepts`` and ``coroutines`` should be evaluated carefully. -When using C++20 features, be careful about readability for developers familiar only with C++14. +When using C++17 and C++20 features, be careful about readability for developers familiar only with C++14. If you find that any Style Guide rules conflict with C++20 best practices, such as those in the `C++ Core Guidelines`_, please propose updates.