Difference between revisions of "C++20"

From Inkscape Wiki
Jump to navigation Jump to search
Line 6: Line 6:
{| class="wikitable"
{| class="wikitable"
|-
|-
! Feature !! Since !! Can use? !! Comment
! Feature                           !! Since !! Can use?                                   !! Apple Clang !! Comment
|-
|-
| <code>std::span</code> || C++20 || style="background: lightgreen;" | from 1.3? || Handle buffers like standard library containers without risk of overflow. (OK on MacOS)
| <code>std::span</code>           || C++20 || style="background: lightgreen;" | from 1.3? || 11.0.3 || Handle buffers like standard library containers without risk of overflow.
|-
|-
| <code>std::format</code>|| C++20 || style="background: lightgreen;" | from 1.4? || Better and more efficient formatting of strings.
| <code>std::format</code>         || C++20 || style="background: pink;"       |           || N/A    || Better and more efficient formatting of strings.
|-
|-
| <code>std::lerp</code> || C++20 ||                                   from 1.4? || Linear interpolation.
| <code>std::lerp</code>           || C++20 || style="background: lightgreen;" | from 1.4? || 11.0.3 || Linear interpolation. (ui/tools/pencil-tool.cpp)
|-
|-
| <code>std::bit_floor</code> || C++20 ||                               from 1.4? ||  
| <code>std::bit_floor</code>       || C++20 || style="background: lightgreen;" | from 1.4? || 11.0.3/13.0.0 || (helper/mathfns.h)
|-
|-
| <code>Concepts</code   || C++20 ||                                  from 1.4? || Safer templating.
| <code>Concepts</code>            || C++20 ||                                  from 1.4? || 12.0.0 Partial || Safer templating. (ui/controller.h)
|-
|-
| <code>std::make_unique_for_overwrite</code> || C++20 ||               from 1.4? ||
| <code>Coroutines</code>           || C++20 ||                                             || 10.0.1 Partial || (trace/trace.cpp)
|-
|-
| <code>Ranges</code>     || C++20 ||                                   from 1.4? ||
| <code>std::make_unique_for_overwrite</code> || C++20 || style="background: pink;" |      || N/A    || (util/pool.cpp)
|-
|-
| <code>Structural Templates</code> || C++20 ||                         from 1.4? ||
| <code>Ranges</code>              || C++20 ||                                  from 1.4? || ?      || for (init; decl : expr). (ui/dialog/swatches.cpp)
|-
| <code>Structural Templates</code> || C++20 ||                                   from 1.4? || ?      || (display/drawing.cpp)
|}
|}
As of 1 September 2023, the CI runners for MacOS are using Apple Clang 13.1.6 (ARM) and Apple Clang 14.0.0 (Intel64).

Revision as of 16:06, 1 September 2023

See also C++11, C++17.

Some things that will be interesting to use once C++20 is common:

Feature Since Can use? Apple Clang Comment
std::span C++20 from 1.3? 11.0.3 Handle buffers like standard library containers without risk of overflow.
std::format C++20 N/A Better and more efficient formatting of strings.
std::lerp C++20 from 1.4? 11.0.3 Linear interpolation. (ui/tools/pencil-tool.cpp)
std::bit_floor C++20 from 1.4? 11.0.3/13.0.0 (helper/mathfns.h)
Concepts C++20 from 1.4? 12.0.0 Partial Safer templating. (ui/controller.h)
Coroutines C++20 10.0.1 Partial (trace/trace.cpp)
std::make_unique_for_overwrite C++20 N/A (util/pool.cpp)
Ranges C++20 from 1.4? ? for (init; decl : expr). (ui/dialog/swatches.cpp)
Structural Templates C++20 from 1.4? ? (display/drawing.cpp)

As of 1 September 2023, the CI runners for MacOS are using Apple Clang 13.1.6 (ARM) and Apple Clang 14.0.0 (Intel64).