totally_ordered_wrapper: add reset(P) function
The ctor is explicit so there should not be an assignment operator op=. Changing the assignment to = Qt::totally_ordered_wrapper(ptr) is also possible but if ptr is nullptr, I have to forward declare a pointer as follow "T *n = nullptr" and then call Qt::totally_ordered_wrapper(n). So I think adding reset(P) function is better. Found in API Review. Change-Id: I0acfcacc97a43f3cf8bfa65b2b16a65cae95b727 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit dc49d84abc35dfbbc4028a5f86017786cff13ae7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
814dc9715b
commit
8d907213ef
@ -651,6 +651,7 @@ public:
|
||||
explicit constexpr totally_ordered_wrapper(P p) noexcept : ptr(p) {}
|
||||
|
||||
constexpr P get() const noexcept { return ptr; }
|
||||
constexpr void reset(P p) noexcept { ptr = p; }
|
||||
constexpr P operator->() const noexcept { return get(); }
|
||||
constexpr T& operator*() const noexcept { return *get(); }
|
||||
|
||||
|
@ -616,6 +616,8 @@ QT_WARNING_POP
|
||||
QCOMPARE_NE(Qt::compareThreeWay(b.get(), dWrapper), Qt::strong_ordering::equivalent);
|
||||
QCOMPARE_EQ(Qt::compareThreeWay(bWrapper, nullptr), Qt::strong_ordering::greater);
|
||||
QCOMPARE_EQ(Qt::compareThreeWay(nullptr, dWrapper), Qt::strong_ordering::less);
|
||||
dWrapper.reset(nullptr);
|
||||
QCOMPARE_EQ(Qt::compareThreeWay(nullptr, dWrapper), Qt::strong_ordering::equivalent);
|
||||
|
||||
#undef TEST_BUILTIN
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user