Combine qAsConst() with copyAsConst() to asConst()

This commit is contained in:
thalieht
2018-11-27 22:15:04 +02:00
parent 6b1d26d555
commit 1f36b8b89f
57 changed files with 199 additions and 202 deletions

View File

@@ -33,16 +33,13 @@
const char C_TORRENT_FILE_EXTENSION[] = ".torrent";
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
template <typename T>
constexpr typename std::add_const<T>::type &qAsConst(T &t) noexcept { return t; }
constexpr typename std::add_const<T>::type &asConst(T &t) noexcept { return t; }
// prevent rvalue arguments:
// Forward rvalue as const
template <typename T>
void qAsConst(const T &&) = delete;
#endif
constexpr typename std::add_const<T>::type asConst(T &&t) noexcept { return std::move(t); }
// returns a const object copy
// Prevent const rvalue arguments
template <typename T>
constexpr typename std::add_const<T>::type copyAsConst(T &&t) noexcept { return std::move(t); }
void asConst(const T &&) = delete;