diff options
Diffstat (limited to 'src/corelib/tools/qcontainertools_impl.h')
-rw-r--r-- | src/corelib/tools/qcontainertools_impl.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/corelib/tools/qcontainertools_impl.h b/src/corelib/tools/qcontainertools_impl.h index 40ed0a84e9..998bc292d4 100644 --- a/src/corelib/tools/qcontainertools_impl.h +++ b/src/corelib/tools/qcontainertools_impl.h @@ -72,6 +72,8 @@ template <typename T, typename N> void q_uninitialized_relocate_n(T* first, N n, T* out) { if constexpr (QTypeInfo<T>::isRelocatable) { + static_assert(std::is_copy_constructible_v<T> || std::is_move_constructible_v<T>, + "Refusing to relocate this non-copy/non-move-constructible type."); if (n != N(0)) { // even if N == 0, out == nullptr or first == nullptr are UB for memcpy() std::memcpy(static_cast<void *>(out), static_cast<const void *>(first), @@ -252,6 +254,13 @@ void q_relocate_overlap_n(T *first, N n, T *d_first) } } +template <typename T> +struct ArrowProxy +{ + T t; + T *operator->() noexcept { return &t; } +}; + template <typename Iterator> using IfIsInputIterator = typename std::enable_if< std::is_convertible<typename std::iterator_traits<Iterator>::iterator_category, std::input_iterator_tag>::value, @@ -300,7 +309,11 @@ using IfAssociativeIteratorHasKeyAndValue = template <typename Iterator> using IfAssociativeIteratorHasFirstAndSecond = - std::enable_if_t<qxp::is_detected_v<FirstAndSecondTest, Iterator>, bool>; + std::enable_if_t< + std::conjunction_v< + std::negation<qxp::is_detected<KeyAndValueTest, Iterator>>, + qxp::is_detected<FirstAndSecondTest, Iterator> + >, bool>; template <typename Iterator> using MoveBackwardsTest = decltype( @@ -367,8 +380,7 @@ template <typename Container, typename T> auto sequential_erase_with_copy(Container &c, const T &t) { using CopyProxy = std::conditional_t<std::is_copy_constructible_v<T>, T, const T &>; - const T &tCopy = CopyProxy(t); - return sequential_erase(c, tCopy); + return sequential_erase(c, CopyProxy(t)); } template <typename Container, typename T> |