Difference between revisions of "C++20"

From Inkscape Wiki
Jump to navigation Jump to search
(Update to reflect latest CI changes, add new information)
Line 10: Line 10:
| <code>std::span</code>            || C++20 || style="background: lightgreen;" | from 1.4  || 10    || 11.0.3 || Handle buffers like standard library containers without risk of overflow.
| <code>std::span</code>            || C++20 || style="background: lightgreen;" | from 1.4  || 10    || 11.0.3 || Handle buffers like standard library containers without risk of overflow.
|-
|-
| <code>std::format</code>          || C++20 || style="background: pink;"      |  not yet || 13    || N/A    || Better and more efficient formatting of strings. [https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0645r10.html Text Formatting]
| <code>std::format</code>          || C++20 || style="background: pink;"      |  not yet || 13    || 15.3  || Better and more efficient formatting of strings. [https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0645r10.html Text Formatting]
|-
|-
| <code>std::lerp</code>            || C++20 || style="background: lightgreen;" | from 1.4  ||  9    || 11.0.3 || Linear interpolation. (ui/tools/pencil-tool.cpp)
| <code>std::lerp</code>            || C++20 || style="background: lightgreen;" | from 1.4  ||  9    || 11.0.3 || Linear interpolation. (ui/tools/pencil-tool.cpp)
Line 18: Line 18:
| <code>Concepts</code>            || C++20 ||                                  from 1.4? || 6/10  || 12.0.0 Partial || Safer templating. (ui/controller.h)
| <code>Concepts</code>            || C++20 ||                                  from 1.4? || 6/10  || 12.0.0 Partial || Safer templating. (ui/controller.h)
|-
|-
| <code>Coroutines</code>          || C++20 || style="background: pink;" |        not yet || 10    || 10.0.1 Partial || Simpler asynchronous code. (trace/trace.cpp)
| <code>Coroutines</code>          || C++20 || style="background: pink;" |        not yet || 10    || 10.0.1 Partial,<br/> 15.3 Full || Simpler asynchronous code. (trace/trace.cpp)
|-
|-
| <code>std::make_unique_for_overwrite</code>
| <code>std::make_unique_for_overwrite</code>
                                     || C++20 || style="background: pink;" |        not yet || 11    || N/A || Don't zero arrays allocated using std::make_unique. (util/pool.cpp)
                                     || C++20 || style="background: pink;" |        not yet || 11    || 15.0.0 || Don't zero arrays allocated using std::make_unique. (util/pool.cpp)
|-
|-
| <code>Ranges</code>              || C++20 || style="background: pink;" |        not yet ||        || ? || for (init; decl : expr). (ui/dialog/swatches.cpp)
| <code>Ranges</code>              || C++20 || style="background: pink;" |        not yet ||        || ? || for (init; decl : expr). (ui/dialog/swatches.cpp)

Revision as of 10:05, 27 March 2024

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

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

Feature Since Can use? GCC Apple Clang Comment
std::span C++20 from 1.4 10 11.0.3 Handle buffers like standard library containers without risk of overflow.
std::format C++20 not yet 13 15.3 Better and more efficient formatting of strings. Text Formatting
std::lerp C++20 from 1.4 9 11.0.3 Linear interpolation. (ui/tools/pencil-tool.cpp)
std::bit_floor C++20 from 1.4 9/10 11.0.3/13.0.0 Compute floor(log2(x)). (helper/mathfns.h)
Concepts C++20 from 1.4? 6/10 12.0.0 Partial Safer templating. (ui/controller.h)
Coroutines C++20 not yet 10 10.0.1 Partial,
15.3 Full
Simpler asynchronous code. (trace/trace.cpp)
std::make_unique_for_overwrite C++20 not yet 11 15.0.0 Don't zero arrays allocated using std::make_unique. (util/pool.cpp)
Ranges C++20 not yet ? for (init; decl : expr). (ui/dialog/swatches.cpp)
Structural templates C++20 from 1.4? Partial Allow instances of arbitrary literal classes as template parameters. (display/drawing.cpp)
Mathematical Constants C++20 10 12.0.5 Constants like std::numbers::pi.

References:

As of 27 March 2024, the CI runners for the various supported platforms are

  • Linux:
    • appimage:linux: GNU 13.2.0 (building on Ubuntu 23.10)
    • inkscape:linux: Same as above
  • Windows
    • inkscape:windows:build: GNU 13.2.0 (temporarily disabled since GTK4 port)
    • inkscape:windows:dist: Same as above
  • macOS:
    • inkscape::macos:arm: Apple Clang 15.0.0
    • inkscape:macos:x64: Apple Clang 13.0.0 (temporarily disabled since GTK4 port)

We strive to support latest Debian stable and latest Ubuntu LTS. However, we had to break that promise since the GTK4 port, which requires gtkmm4 >= 4.14:

Distro gcc clang gtkmm4
Debian 12 (Bookworm, stable) 12.2.0 15.0.6 4.8.3
Ubuntu 22.04 (Jammy Jellyfish) 12.3.0 15.0.7 Not packaged!
Ubuntu 23.04 (Lunar) 13.1.0 16.0.0 4.10.1

Ubuntu users therefore have the following options:

  • Wait for Ubuntu 24.04, expected around 25 April 2024.
  • Upgrade to Ubuntu 24.04 now.
  • Upgrade to Ubuntu 23.10 and build gtkmm4 from source, as is currently done by CI.
  • ???

Deprecated items that we still use: