diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-03-01 22:21:45 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2023-03-24 06:40:19 +0100 |
commit | a9e8034e8c9207876d97ee98f33f0e8006d12d8d (patch) | |
tree | 74296d37f51ca42b2c932190bbac08a21b063190 /tests/auto/gui/painting/qcolortransform/CMakeLists.txt | |
parent | de3e9708898da6a6480e973308d228b8dcc3b139 (diff) |
Implement [variant.get] for QVariant [2/2]: get()
This second patch of the series implements get().
Unlike other get() implementations in Qt, don't use my trick with the
constrained friend free function here. Instead, provide the four
overloads manually, like mandated by the standard library for
std::variant (and, indeed, tuple), such that these functions can also
be used on subclasses of QVariant.
[ChangeLog][QtCore][QVariant] Implemented the type-based std::variant
access protocol (get<T>()/get_if<T>()) to allow easier access to the
contained element than the previous solution of casting data(), as
well as to allow generic code to treat QVariant and std::variant the
same. The holds_alternative<T>() function is not provided, since it's
the same as get_if<T> != nullptr. The index-based variant access
functions (get<I>()/get_if<I>()) are also not provided, because,
unlike std::variant, QVariant does not have a bounded number of
alternative types, and QMetaType IDs are not (all) compile-time
constants.
Fixes: QTBUG-111598
Change-Id: Id7bc41f7d91761b3483ec5604f1a4685c8079844
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/gui/painting/qcolortransform/CMakeLists.txt')
0 files changed, 0 insertions, 0 deletions