Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QSpan: add missing slice() and chop()
When 9bf68a4 and 8f68bd9 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 <[email protected]>
- Loading branch information