Difference between revisions of "C++20"

From Inkscape Wiki
Jump to navigation Jump to search
(Class types as non-type template parameters -> partial)
Line 6: Line 6:
{| class="wikitable"
{| class="wikitable"
|-
|-
! Feature                          !! Since !! Can use?                                    !! Apple Clang !! Comment
! Feature                          !! Since !! Can use?                                    !! GCC    !! Apple Clang !! Comment
|-
|-
| <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::span</code>            || C++20 || style="background: lightgreen;" | from 1.3? || 10    || 11.0.3 || Handle buffers like standard library containers without risk of overflow.
|-
|-
| <code>std::format</code>          || C++20 || style="background: pink;"      |          || N/A    || Better and more efficient formatting of strings.
| <code>std::format</code>          || C++20 || style="background: pink;"      |          || 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::lerp</code>            || C++20 || style="background: lightgreen;" | from 1.4? || 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)
|-
|-
| <code>std::bit_floor</code>      || C++20 || style="background: lightgreen;" | from 1.4? || 11.0.3/13.0.0 || Compute floor(log2(x)). (helper/mathfns.h)
| <code>std::bit_floor</code>      || C++20 || style="background: lightgreen;" | from 1.4? || 9/10  || 11.0.3/13.0.0 || Compute floor(log2(x)). (helper/mathfns.h)
|-
|-
| <code>Concepts</code>            || C++20 ||                                  from 1.4? || 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 ||                                            || 10.0.1 Partial || Simpler asynchronous code. (trace/trace.cpp)
| <code>Coroutines</code>          || C++20 ||                                            || 10    || 10.0.1 Partial || Simpler asynchronous code. (trace/trace.cpp)
|-
|-
| <code>std::make_unique_for_overwrite</code> || C++20 || style="background: pink;" |      || N/A    || Don't zero arrays allocated using std::make_unique. (util/pool.cpp)
| <code>std::make_unique_for_overwrite</code> || C++20 || style="background: pink;" |      || 11    || N/A    || Don't zero arrays allocated using std::make_unique. (util/pool.cpp)
|-
|-
| <code>Ranges</code>              || C++20 ||                                  from 1.4? || ?      || for (init; decl : expr). (ui/dialog/swatches.cpp)
| <code>Ranges</code>              || C++20 ||                                  from 1.4? ||        || ?      || for (init; decl : expr). (ui/dialog/swatches.cpp)
|-
|-
| <code>[https://stackoverflow.com/a/60244416/5075760 Structural templates]</code> || C++20 ||                                   from 1.4? || Partial      || Allow instances of arbitrary literal classes as template parameters. (display/drawing.cpp)
| <code>[https://stackoverflow.com/a/60244416/5075760 Structural templates]</code> || C++20 || from 1.4? ||  || Partial      || Allow instances of arbitrary literal classes as template parameters. (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).
As of 1 September 2023, the CI runners for:
* Linux:
** appimage:linux GNU 9.4.0
** inkscape:linux GNU 11.4.0
* Windows
** inkscape:windows:build Gnu 13.1.0
** inkscape:windows:dist (ming64) ?
* macOS:
** inkscape::macos:arm Apple Clang 13.1.6
** inkscape:macos:x64: Apple Clang 14.0.0.
 
Errors and Deprecated items that we use:
* error: call of overloaded ‘lerp(double, double&, double&)’ is ambiguous  (ui/knot/knot-holder-entity.cpp)
* warning: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20 [-Wdeprecated] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0806r2.html
* warning: bitwise operation between different enumeration types ‘Box3D::Axis’ and ‘Box3D::FrontOrRear’ is deprecated [-Wdeprecated-enum-enum-conversion]

Revision as of 15:30, 3 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? GCC Apple Clang Comment
std::span C++20 from 1.3? 10 11.0.3 Handle buffers like standard library containers without risk of overflow.
std::format C++20 13 N/A 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 10 10.0.1 Partial Simpler asynchronous code. (trace/trace.cpp)
std::make_unique_for_overwrite C++20 11 N/A Don't zero arrays allocated using std::make_unique. (util/pool.cpp)
Ranges C++20 from 1.4? ? 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)

As of 1 September 2023, the CI runners for:

  • Linux:
    • appimage:linux GNU 9.4.0
    • inkscape:linux GNU 11.4.0
  • Windows
    • inkscape:windows:build Gnu 13.1.0
    • inkscape:windows:dist (ming64) ?
  • macOS:
    • inkscape::macos:arm Apple Clang 13.1.6
    • inkscape:macos:x64: Apple Clang 14.0.0.

Errors and Deprecated items that we use:

  • error: call of overloaded ‘lerp(double, double&, double&)’ is ambiguous (ui/knot/knot-holder-entity.cpp)
  • warning: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20 [-Wdeprecated] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0806r2.html
  • warning: bitwise operation between different enumeration types ‘Box3D::Axis’ and ‘Box3D::FrontOrRear’ is deprecated [-Wdeprecated-enum-enum-conversion]