Skip to content

Commit 975b693

Browse files
authored
Merge pull request #718 from lsst-dm/tickets/DM-50434
DM-50434: Update for C++20
2 parents f67093f + 5797247 commit 975b693

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

cpp/style.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,25 @@ These tasks are made much simpler if the code is easily readable and well-docume
8484

8585
.. _style-guide-cpp-2-2:
8686

87-
2-2. We are writing C++17
87+
2-2. We are writing C++20
8888
-------------------------
8989

90-
We follow the official: International Standard ISO/IEC 14882:2017(E) – Programming Language C++, without any compiler specific extensions.
90+
We follow the official: International Standard ISO/IEC 14882:2024(E) – Programming Language C++, without any compiler specific extensions.
9191

9292
.. note::
9393

9494
We use compilers provided by a specific :ref:`Conda environment <platforms-environment>` executing on a defined :ref:`baseline platform <platforms-baseline>`.
95-
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.
95+
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.
9696
In practice, we further restrict the feature set to those that also work on our commonly-tested platforms.
9797

98-
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``.
99-
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.
100-
``std::auto_ptr`` has been removed and should typically be replaced by ``std::unique_ptr``.
98+
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``.
99+
It also includes enhancements of the standard library including ``ranges``, definition of mathematical constants in ``<numbers>``, ``std::format``, ``std::span``, improved calendar and timezone support in ``chrono``.
101100

102-
When using C++17 features, be careful about readability for developers familiar only with C++14.
101+
The use of ``modules`` is discouraged. The use of ``concepts`` and ``coroutines`` should be evaluated carefully.
103102

104-
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.
103+
When using C++17 and C++20 features, be careful about readability for developers familiar only with C++14.
104+
105+
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.
105106

106107
.. _C++ Core Guidelines: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md
107108

0 commit comments

Comments
 (0)