* [committed] libstdc++: Add comparison operators to <charconv> result types
@ 2020-04-08 15:17 Jonathan Wakely
2020-04-08 15:52 ` [committed] libstdc++: Add comparison operators to types from Numerics clause Jonathan Wakely
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2020-04-08 15:17 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 341 bytes --]
Some more C++20 changes from P1614R2, "The Mothership has Landed".
* include/std/charconv (to_chars_result, from_chars_result): Add
defaulted equality comparisons for C++20.
* testsuite/20_util/from_chars/compare.cc: New test.
* testsuite/20_util/to_chars/compare.cc: New test.
Tested powerpc64le-linux, committed to master.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 5204 bytes --]
commit e18cd376e0d5ffc2a2b21eba0c396a771c30e1d4
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Apr 8 16:16:10 2020 +0100
libstdc++: Add comparison operators to <charconv> result types
Some more C++20 changes from P1614R2, "The Mothership has Landed".
* include/std/charconv (to_chars_result, from_chars_result): Add
defaulted equality comparisons for C++20.
* testsuite/20_util/from_chars/compare.cc: New test.
* testsuite/20_util/to_chars/compare.cc: New test.
diff --git a/libstdc++-v3/include/std/charconv b/libstdc++-v3/include/std/charconv
index 8c9ce9d280e..3caa0f8ac10 100644
--- a/libstdc++-v3/include/std/charconv
+++ b/libstdc++-v3/include/std/charconv
@@ -44,7 +44,8 @@
#include <bits/error_constants.h> // for std::errc
#include <bits/int_limits.h>
-// Define when floating point is supported: #define __cpp_lib_to_chars 201611L
+// FIXME: Define when floating point is supported:
+// #define __cpp_lib_to_chars 201611L
namespace std _GLIBCXX_VISIBILITY(default)
{
@@ -55,6 +56,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
char* ptr;
errc ec;
+
+#if __cplusplus > 201703L && __cpp_impl_three_way_comparison >= 201907L
+ friend bool
+ operator==(const to_chars_result&, const to_chars_result&) = default;
+#endif
};
/// Result type of std::from_chars
@@ -62,6 +68,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
const char* ptr;
errc ec;
+
+#if __cplusplus > 201703L && __cpp_impl_three_way_comparison >= 201907L
+ friend bool
+ operator==(const from_chars_result&, const from_chars_result&) = default;
+#endif
};
namespace __detail
diff --git a/libstdc++-v3/testsuite/20_util/from_chars/compare.cc b/libstdc++-v3/testsuite/20_util/from_chars/compare.cc
new file mode 100644
index 00000000000..04d51afa4e3
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/from_chars/compare.cc
@@ -0,0 +1,50 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <charconv>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::from_chars_result r1{}, r2{};
+ VERIFY( r1 == r1 );
+ VERIFY( !(r1 != r1) );
+ VERIFY( r2 == r1 );
+ VERIFY( !(r2 != r1) );
+ r1.ptr = "";
+ VERIFY( r1 == r1 );
+ VERIFY( r1 != r2 );
+ r2.ptr = "a" + 1;
+ VERIFY( r1 != r2 );
+ r2.ptr = r1.ptr;
+ r2.ec = std::errc::invalid_argument;
+ VERIFY( r1 != r2 );
+ r1.ec = std::errc::no_such_file_or_directory;
+ VERIFY( r1 != r2 );
+ r1.ec = std::errc::invalid_argument;
+ VERIFY( r2 == r1 );
+}
+
+int
+main()
+{
+ test01();
+}
diff --git a/libstdc++-v3/testsuite/20_util/to_chars/compare.cc b/libstdc++-v3/testsuite/20_util/to_chars/compare.cc
new file mode 100644
index 00000000000..64232955956
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/to_chars/compare.cc
@@ -0,0 +1,51 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <charconv>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ char str[2]{};
+ std::to_chars_result r1{}, r2{};
+ VERIFY( r1 == r1 );
+ VERIFY( !(r1 != r1) );
+ VERIFY( r2 == r1 );
+ VERIFY( !(r2 != r1) );
+ r1.ptr = str;
+ VERIFY( r1 == r1 );
+ VERIFY( r1 != r2 );
+ r2.ptr = str + 1;
+ VERIFY( r1 != r2 );
+ r2.ptr = r1.ptr;
+ r2.ec = std::errc::invalid_argument;
+ VERIFY( r1 != r2 );
+ r1.ec = std::errc::no_such_file_or_directory;
+ VERIFY( r1 != r2 );
+ r1.ec = std::errc::invalid_argument;
+ VERIFY( r2 == r1 );
+}
+
+int
+main()
+{
+ test01();
+}
^ permalink raw reply [flat|nested] 3+ messages in thread
* [committed] libstdc++: Add comparison operators to types from Numerics clause
2020-04-08 15:17 [committed] libstdc++: Add comparison operators to <charconv> result types Jonathan Wakely
@ 2020-04-08 15:52 ` Jonathan Wakely
2020-04-09 20:12 ` [committed] libstdc++: Add comparison operators to std::unique_ptr Jonathan Wakely
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2020-04-08 15:52 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 566 bytes --]
Some more C++20 changes from P1614R2, "The Mothership has Landed".
* include/bits/slice_array.h (operator==(const slice&, const slice&)):
Define for C++20.
* include/std/complex (operator==(const T&, const complex<T>&))
(operator!=(const complex<T>&, const complex<T>&))
(operator!=(const complex<T>&, const T&))
(operator!=(const T&, const complex<T>&)): Do not declare for C++20.
* testsuite/26_numerics/slice/compare.cc: New test.
Tested powerpc64le-linux, committed to master.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 3837 bytes --]
commit ef389dadd4f082e13b076f14a123bf506e158da4
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Apr 8 16:51:59 2020 +0100
libstdc++: Add comparison operators to types from Numerics clause
Some more C++20 changes from P1614R2, "The Mothership has Landed".
* include/bits/slice_array.h (operator==(const slice&, const slice&)):
Define for C++20.
* include/std/complex (operator==(const T&, const complex<T>&))
(operator!=(const complex<T>&, const complex<T>&))
(operator!=(const complex<T>&, const T&))
(operator!=(const T&, const complex<T>&)): Do not declare for C++20.
* testsuite/26_numerics/slice/compare.cc: New test.
diff --git a/libstdc++-v3/include/bits/slice_array.h b/libstdc++-v3/include/bits/slice_array.h
index 32ba802c007..de33342e252 100644
--- a/libstdc++-v3/include/bits/slice_array.h
+++ b/libstdc++-v3/include/bits/slice_array.h
@@ -78,6 +78,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Return array stride of slice.
size_t stride() const;
+#if __cpp_impl_three_way_comparison >= 201907L
+ /// Equality comparison
+ friend bool operator==(const slice&, const slice&) = default;
+#endif
+
private:
size_t _M_off; // offset
size_t _M_sz; // size
diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex
index 4f170dc524a..f2917b8c368 100644
--- a/libstdc++-v3/include/std/complex
+++ b/libstdc++-v3/include/std/complex
@@ -468,6 +468,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator==(const complex<_Tp>& __x, const _Tp& __y)
{ return __x.real() == __y && __x.imag() == _Tp(); }
+#if !(__cpp_impl_three_way_comparison >= 201907L)
template<typename _Tp>
inline _GLIBCXX_CONSTEXPR bool
operator==(const _Tp& __x, const complex<_Tp>& __y)
@@ -490,6 +491,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
inline _GLIBCXX_CONSTEXPR bool
operator!=(const _Tp& __x, const complex<_Tp>& __y)
{ return __x != __y.real() || _Tp() != __y.imag(); }
+#endif
//@}
/// Extraction operator for complex values.
diff --git a/libstdc++-v3/testsuite/26_numerics/slice/compare.cc b/libstdc++-v3/testsuite/26_numerics/slice/compare.cc
new file mode 100644
index 00000000000..4459cf22eb6
--- /dev/null
+++ b/libstdc++-v3/testsuite/26_numerics/slice/compare.cc
@@ -0,0 +1,48 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <valarray>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::slice s1(1, 2, 3);
+ VERIFY( s1 == s1 );
+ VERIFY( !(s1 != s1) );
+ std::slice s2(1, 2, 3);
+ VERIFY( s2 == s1 );
+ VERIFY( !(s2 != s1) );
+ std::slice s3(3, 2, 3);
+ VERIFY( s3 != s1 );
+ VERIFY( !(s3 == s1) );
+ std::slice s4(1, 3, 3);
+ VERIFY( s4 != s1 );
+ VERIFY( !(s4 == s1) );
+ std::slice s5(1, 2, 4);
+ VERIFY( s5 != s1 );
+ VERIFY( !(s5 == s1) );
+}
+
+int
+main()
+{
+ test01();
+}
^ permalink raw reply [flat|nested] 3+ messages in thread
* [committed] libstdc++: Add comparison operators to std::unique_ptr
2020-04-08 15:52 ` [committed] libstdc++: Add comparison operators to types from Numerics clause Jonathan Wakely
@ 2020-04-09 20:12 ` Jonathan Wakely
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2020-04-09 20:12 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 825 bytes --]
Some more C++20 changes from P1614R2, "The Mothership has Landed".
This includes the proposed resolution for LWG 3426 to fix the three-way
comparison with nullptr_t.
The existing tests for unique_ptr comparisons don't actually check the
results, only that the expressions compile and are convertible to bool.
This also adds a test for the results of those comparisons for C++11 and
up.
* include/bits/unique_ptr.h (operator<=>): Define for C++20.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust dg-error line.
* testsuite/20_util/default_delete/void_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/comparison/compare.cc: New test.
* testsuite/20_util/unique_ptr/comparison/compare_c++20.cc: New test.
Tested powerpc64le-linux, committed to master.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 10000 bytes --]
commit 5b074864f8c593fd4bccee788a023a37b446b2ed
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Apr 9 21:10:32 2020 +0100
libstdc++: Add comparison operators to std::unique_ptr
Some more C++20 changes from P1614R2, "The Mothership has Landed".
This includes the proposed resolution for LWG 3426 to fix the three-way
comparison with nullptr_t.
The existing tests for unique_ptr comparisons don't actually check the
results, only that the expressions compile and are convertible to bool.
This also adds a test for the results of those comparisons for C++11 and
up.
* include/bits/unique_ptr.h (operator<=>): Define for C++20.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust dg-error line.
* testsuite/20_util/default_delete/void_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/comparison/compare.cc: New test.
* testsuite/20_util/unique_ptr/comparison/compare_c++20.cc: New test.
diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h
index d03266c1878..53c8def627d 100644
--- a/libstdc++-v3/include/bits/unique_ptr.h
+++ b/libstdc++-v3/include/bits/unique_ptr.h
@@ -37,6 +37,9 @@
#include <tuple>
#include <bits/stl_function.h>
#include <bits/functional_hash.h>
+#if __cplusplus > 201703L
+# include <compare>
+#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
@@ -756,6 +759,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator==(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) noexcept
{ return !__x; }
+#ifndef __cpp_lib_three_way_comparison
/// unique_ptr comparison with nullptr
template<typename _Tp, typename _Dp>
_GLIBCXX_NODISCARD inline bool
@@ -781,6 +785,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_NODISCARD inline bool
operator!=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) noexcept
{ return (bool)__x; }
+#endif // three way comparison
/// Relational operator for unique_ptr objects, compares the owned pointers
template<typename _Tp, typename _Dp,
@@ -878,6 +883,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_NODISCARD inline bool
operator>=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x)
{ return !(nullptr < __x); }
+
+#ifdef __cpp_lib_three_way_comparison
+ template<typename _Tp, typename _Dp, typename _Up, typename _Ep>
+ requires three_way_comparable_with<typename unique_ptr<_Tp, _Dp>::pointer,
+ typename unique_ptr<_Up, _Ep>::pointer>
+ compare_three_way_result_t<typename unique_ptr<_Tp, _Dp>::pointer,
+ typename unique_ptr<_Up, _Ep>::pointer>
+ operator<=>(const unique_ptr<_Tp, _Dp>& __x,
+ const unique_ptr<_Up, _Ep>& __y)
+ { return compare_three_way()(__x.get(), __y.get()); }
+
+ template<typename _Tp, typename _Dp>
+ requires three_way_comparable<typename unique_ptr<_Tp, _Dp>::pointer>
+ compare_three_way_result_t<typename unique_ptr<_Tp, _Dp>::pointer>
+ operator<=>(const unique_ptr<_Tp, _Dp>& __x, nullptr_t)
+ {
+ using pointer = typename unique_ptr<_Tp, _Dp>::pointer;
+ return compare_three_way()(__x.get(), pointer(nullptr));
+ }
+#endif
// @} relates unique_ptr
/// @cond undocumented
diff --git a/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc b/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc
index 57d7e62c310..6da5a52e28b 100644
--- a/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc
@@ -26,4 +26,4 @@ struct D : B { };
D d;
std::default_delete<B[]> db;
typedef decltype(db(&d)) type; // { dg-error "no match" }
-// { dg-error "no type" "" { target *-*-* } 112 }
+// { dg-error "no type" "" { target *-*-* } 115 }
diff --git a/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc b/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc
index 0c5a09e1e9d..149b699d106 100644
--- a/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc
@@ -25,5 +25,5 @@ void test01()
{
std::default_delete<void> d;
d(nullptr); // { dg-error "here" }
- // { dg-error "incomplete" "" { target *-*-* } 77 }
+ // { dg-error "incomplete" "" { target *-*-* } 80 }
}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/compare.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/compare.cc
new file mode 100644
index 00000000000..e293b27904e
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/compare.cc
@@ -0,0 +1,88 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run { target c++11 } }
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::unique_ptr<int> p0, p00;
+ VERIFY( p0 == p00 );
+ VERIFY( !(p0 < p00) );
+ VERIFY( !(p0 > p00) );
+ VERIFY( p0 <= p00 );
+ VERIFY( p0 >= p00 );
+
+ std::unique_ptr<int> p1(new int(1));
+ VERIFY( p1 == p1 );
+ VERIFY( !(p1 < p1) );
+ VERIFY( !(p1 > p1) );
+ VERIFY( p1 <= p1 );
+ VERIFY( p1 >= p1 );
+
+ std::unique_ptr<const int> p2(new int(1));
+ VERIFY( p1 >= p1 );
+ VERIFY( p1 != p2 );
+ VERIFY( (p1 < p2) || (p1 > p2) );
+ VERIFY( (p1 <= p2) || (p1 >= p2) );
+
+ VERIFY( p1 != p0 );
+ VERIFY( !(p1 < p0) );
+ VERIFY( p1 > p0 );
+ VERIFY( !(p1 <= p0) );
+ VERIFY( p1 >= p0 );
+}
+
+void
+test02()
+{
+ std::unique_ptr<int> p0;
+ VERIFY( p0 == nullptr );
+ VERIFY( !(p0 < nullptr) );
+ VERIFY( !(p0 > nullptr) );
+ VERIFY( p0 <= nullptr );
+ VERIFY( p0 >= nullptr );
+
+ VERIFY( nullptr == p0 );
+ VERIFY( !(nullptr < p0) );
+ VERIFY( !(nullptr > p0) );
+ VERIFY( nullptr <= p0 );
+ VERIFY( nullptr >= p0 );
+
+ std::unique_ptr<int> p1(new int(1));
+ VERIFY( p1 != nullptr );
+ VERIFY( !(p1 < nullptr) );
+ VERIFY( p1 > nullptr );
+ VERIFY( !(p1 <= nullptr) );
+ VERIFY( p1 >= nullptr );
+
+ VERIFY( nullptr != p1 );
+ VERIFY( nullptr < p1 );
+ VERIFY( !(nullptr > p1) );
+ VERIFY( nullptr <= p1 );
+ VERIFY( !(nullptr >= p1) );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/compare_c++20.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/compare_c++20.cc
new file mode 100644
index 00000000000..be9819f8de1
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/compare_c++20.cc
@@ -0,0 +1,98 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::unique_ptr<int> p0, p00;
+ VERIFY( p0 == p00 );
+ VERIFY( !(p0 < p00) );
+ VERIFY( !(p0 > p00) );
+ VERIFY( p0 <= p00 );
+ VERIFY( p0 >= p00 );
+ VERIFY( std::is_eq(p0 <=> p00) );
+
+ std::unique_ptr<int> p1(new int(1));
+ VERIFY( p1 == p1 );
+ VERIFY( !(p1 < p1) );
+ VERIFY( !(p1 > p1) );
+ VERIFY( p1 <= p1 );
+ VERIFY( p1 >= p1 );
+ VERIFY( std::is_eq(p1 <=> p1) );
+
+ std::unique_ptr<const int> p2(new int(1));
+ VERIFY( p1 >= p1 );
+ VERIFY( p1 != p2 );
+ VERIFY( (p1 < p2) || (p1 > p2) );
+ VERIFY( (p1 <= p2) || (p1 >= p2) );
+ VERIFY( std::is_neq(p1 <=> p2) );
+
+ VERIFY( p1 != p0 );
+ VERIFY( !(p1 < p0) );
+ VERIFY( p1 > p0 );
+ VERIFY( !(p1 <= p0) );
+ VERIFY( p1 >= p0 );
+ VERIFY( std::is_gt(p1 <=> p0) );
+ VERIFY( std::is_lt(p0 <=> p1) );
+}
+
+void
+test02()
+{
+ std::unique_ptr<int> p0;
+ VERIFY( p0 == nullptr );
+ VERIFY( !(p0 < nullptr) );
+ VERIFY( !(p0 > nullptr) );
+ VERIFY( p0 <= nullptr );
+ VERIFY( p0 >= nullptr );
+ VERIFY( std::is_eq(p0 <=> nullptr) );
+
+ VERIFY( nullptr == p0 );
+ VERIFY( !(nullptr < p0) );
+ VERIFY( !(nullptr > p0) );
+ VERIFY( nullptr <= p0 );
+ VERIFY( nullptr >= p0 );
+ VERIFY( std::is_eq(nullptr <=> p0) );
+
+ std::unique_ptr<int> p1(new int(1));
+ VERIFY( p1 != nullptr );
+ VERIFY( !(p1 < nullptr) );
+ VERIFY( p1 > nullptr );
+ VERIFY( !(p1 <= nullptr) );
+ VERIFY( p1 >= nullptr );
+ VERIFY( std::is_gt(p1 <=> nullptr) );
+
+ VERIFY( nullptr != p1 );
+ VERIFY( nullptr < p1 );
+ VERIFY( !(nullptr > p1) );
+ VERIFY( nullptr <= p1 );
+ VERIFY( !(nullptr >= p1) );
+ VERIFY( std::is_lt(nullptr <=> p1) );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-09 20:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-08 15:17 [committed] libstdc++: Add comparison operators to <charconv> result types Jonathan Wakely
2020-04-08 15:52 ` [committed] libstdc++: Add comparison operators to types from Numerics clause Jonathan Wakely
2020-04-09 20:12 ` [committed] libstdc++: Add comparison operators to std::unique_ptr Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).