forked from boostorg/utility
Attempt to work around C++20 operator rewriting causinginfinite recursion.
Fixes https://github.com/boostorg/utility/issues/65.
This commit is contained in:
1 parent
37168a3f4b
commit
f3963f5375
3 files changed
+46
-2
No files matched your search
@@ -568,6 +568,25 @@ namespace
|
||||
int v;
|
||||
};
|
||||
|
||||
// Test type designed specifically to test C++20 operator rewriting support
|
||||
struct my_int :
|
||||
public boost::equality_comparable2< my_int, int >
|
||||
{
|
||||
explicit my_int(int n) : m_n(n) {}
|
||||
|
||||
operator int () const
|
||||
{
|
||||
return m_n;
|
||||
}
|
||||
|
||||
bool operator== (my_int that)
|
||||
{
|
||||
return that.m_n == m_n;
|
||||
}
|
||||
|
||||
int m_n;
|
||||
};
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
|
||||
@@ -932,5 +951,11 @@ main()
|
||||
|
||||
cout << "Performed tests on MyLongInt objects.\n";
|
||||
|
||||
my_int my_n = my_int(10);
|
||||
|
||||
// Test if C++20 operator rewriting causes infinite recursion (https://github.com/boostorg/utility/issues/65)
|
||||
BOOST_TEST(my_n == 10);
|
||||
BOOST_TEST(my_n != 20);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
Reference in new issue
Block a user