QGIM: add static assert for optional model and rows

In C++26, std::optional has range semantics, so it's better to
prohibit using this, and decide later on how it should behave.

Change-Id: Ia0dc4b124e74d817ff08ee0db1ce8a54caa83724
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Artem Dyomin 2025-05-02 20:21:31 +02:00 committed by Volker Hilsheimer
parent ed934ec497
commit 9f4d74ece8

View File

@ -204,6 +204,12 @@ public:
using row_type = std::remove_reference_t<row_reference>;
using protocol_type = QGenericItemModelDetails::wrapped_t<Protocol>;
static_assert(!QGenericItemModelDetails::is_any_of<range_type, std::optional>() &&
!QGenericItemModelDetails::is_any_of<row_type, std::optional>(),
"Currently, std::optional is not supported for ranges and rows, as "
"it has range semantics in c++26. Once the required behavior is clarified, "
"std::optional for ranges and rows will be supported.");
protected:
using Self = QGenericItemModelImpl<Structure, Range, Protocol>;
Structure& that() { return static_cast<Structure &>(*this); }