summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2024-11-28 11:45:23 +0100
committerMarc Mutz <marc.mutz@qt.io>2024-12-05 17:19:07 +0100
commit7b0097560359e038be006507e23f52c04263e207 (patch)
treeedd6c8d59b7edeeb5a9f749a315d9b15808fc2bb /src/corelib/kernel/qobject.cpp
parent43e166bd084f4bae6fd348579ed5c27ebf8320e2 (diff)
QSpan: add missing slice() and chop()
When 9bf68a47e1ba8790fca9d24bcb7b45cd56e79320 and 8f68bd9e6353a42d3b71d893b27fec6bedced501 added action versions of the sliced() transformation to QString/QByteArray and the string views, QSpan, which also has sliced(), was forgotten. Add slice(), and since QSpan recently gained chopped(), also add chop() (which the other Qt classes had for ages). These functions only make sense on variable-sized spans, so constrain them. I don't want these functions to be templates, because subspan-ish functions that return fixed-size spans (e.g. last<10>()) take numbers as template arguments, and that's possible here, too, but wrong. So in C++20, use a requires clause that allows to constrain a non-template, so users won't be tempted to pass template arguments. OTOH, I don't want stuff to accidentally compile in C++17 mode (these functions do compile, but are unable to meet their preconditions, unless you pass 0) and then hit a runtime error, or SFINAE out in C++20, so I need to support C++17 constraints, too. Used a macro to paper over the difference. Documentation will come as a follow-up, since this author is still fighting qdoc there, and the Qt 6.9 feature freeze is looming. [ChangeLog][QtCore][QSpan] Added slice() and chop(), being in-place versions of sliced() and chopped(), resp. Fixes: QTBUG-131672 Change-Id: I5832744584549c19e5e25ef8215484874f77af02 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/corelib/kernel/qobject.cpp')
0 files changed, 0 insertions, 0 deletions