Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions cpp/style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this 2020?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2020 is withdrawn, 2024 is the latest ISO document.


.. note::

We use compilers provided by a specific :ref:`Conda environment <platforms-environment>` executing on a defined :ref:`baseline platform <platforms-baseline>`.
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 ``<numbers>``, ``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++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.

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

Expand Down