mirror of
https://github.com/boostorg/utility.git
synced 2025-10-11 08:05:21 +02:00
Compare commits
4 Commits
boost-1.74
...
feature/fi
Author | SHA1 | Date | |
---|---|---|---|
|
f3963f5375 | ||
|
37168a3f4b | ||
|
e56171989a | ||
|
f00a5bf0d3 |
@@ -15,9 +15,10 @@ branches:
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
|
||||
- TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
|
||||
ADDRMD: 32
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
- TOOLSET: msvc-14.0
|
||||
- TOOLSET: msvc-12.0,msvc-14.0
|
||||
ADDRMD: 32,64
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
- TOOLSET: msvc-14.1
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[/
|
||||
/ Copyright (c) 2008 Howard Hinnant
|
||||
/ Copyright (c) 2009-20012 Vicente J. Botet Escriba
|
||||
/ Copyright (c) 2009-2012 Vicente J. Botet Escriba
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
@@ -100,6 +100,11 @@
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/core/addressof.hpp>
|
||||
#if defined(__cpp_impl_three_way_comparison)
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/declval.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__)
|
||||
# pragma set woff 1234
|
||||
@@ -158,9 +163,21 @@ struct less_than_comparable1 : B
|
||||
template <class T, class U, class B = operators_detail::empty_base<T> >
|
||||
struct equality_comparable2 : B
|
||||
{
|
||||
#if defined(__cpp_impl_three_way_comparison)
|
||||
template< typename R = decltype(boost::declval< T const& >() == boost::declval< U const& >()) >
|
||||
friend BOOST_OPERATORS_CONSTEXPR
|
||||
typename boost::enable_if_c< !boost::is_same< R, bool >::value, bool >::type
|
||||
operator==(const U& y, const T& x) { return x == y; }
|
||||
|
||||
template< typename R = decltype(boost::declval< T const& >() == boost::declval< U const& >()) >
|
||||
friend BOOST_OPERATORS_CONSTEXPR
|
||||
typename boost::enable_if_c< !boost::is_same< R, bool >::value, bool >::type
|
||||
operator!=(const U& y, const T& x) { return !static_cast<bool>(x == y); }
|
||||
#else
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator==(const U& y, const T& x) { return x == y; }
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator!=(const U& y, const T& x) { return !static_cast<bool>(x == y); }
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator!=(const T& y, const U& x) { return !static_cast<bool>(y == x); }
|
||||
#endif
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator!=(const T& x, const U& y) { return !static_cast<bool>(x == y); }
|
||||
};
|
||||
|
||||
template <class T, class B = operators_detail::empty_base<T> >
|
||||
|
@@ -144,9 +144,11 @@ struct less_than_comparable1 : B
|
||||
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||
struct equality_comparable2 : B
|
||||
{
|
||||
#if !defined(__cpp_impl_three_way_comparison)
|
||||
friend bool operator==(const U& y, const T& x) { return x == y; }
|
||||
friend bool operator!=(const U& y, const T& x) { return !static_cast<bool>(x == y); }
|
||||
friend bool operator!=(const T& y, const U& x) { return !static_cast<bool>(y == x); }
|
||||
#endif
|
||||
friend bool operator!=(const T& x, const U& y) { return !static_cast<bool>(x == y); }
|
||||
};
|
||||
|
||||
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||
|
@@ -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