diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-10-25 14:42:40 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-10-26 19:27:03 -0700 |
commit | f193c2ef08d0edb1f40b6011a205eb8603c6019b (patch) | |
tree | 3faddb9bfd5a2c9fe769af04b60ff8bc50a9fa12 /commands/command_base.h | |
parent | 1a0cf0bb4432d97c1f34d53b82631629bcb06b8b (diff) | |
download | subsurface-f193c2ef08d0edb1f40b6011a205eb8603c6019b.tar.gz |
cleanup: fix deprecated QVector constructor
Annoyingly, the replacement has only been available since Qt 5.14.
To make the code less messy, implement our own stdToQt conversion helper.
Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'commands/command_base.h')
-rw-r--r-- | commands/command_base.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/commands/command_base.h b/commands/command_base.h index d805610e5..8c905d09a 100644 --- a/commands/command_base.h +++ b/commands/command_base.h @@ -139,6 +139,17 @@ // v.clear(v); // Reset the vector to zero length. If the elements weren't release()d, // // the pointed-to dives are freed with free_dive() +// Qt is making their containers a lot harder to integrate with std::vector +template<typename T> +QVector<T> stdToQt(const std::vector<T> &v) +{ +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + return QVector<T>(v.begin(), v.end()); +#else + return QVector<T>::fromStdVector(v); +#endif +} + // We put everything in a namespace, so that we can shorten names without polluting the global namespace namespace Command { |