+2017-03-12 Ville Voutilainen <ville.voutilainen@gmail.com>
+
+ Implement LWG 2934, optional<const T> doesn't compare with T.
+ * include/std/optional
+ (operator==(const optional<_Tp>&, const optional<_Tp>&)):
+ Turn into operator==(const optional<_Tp>&, const optional<_Up>&).
+ (operator!=(const optional<_Tp>&, const optional<_Tp>&)):
+ Turn into operator!=(const optional<_Tp>&, const optional<_Up>&).
+ (operator<(const optional<_Tp>&, const optional<_Tp>&)):
+ Turn into operator<(const optional<_Tp>&, const optional<_Up>&.
+ (operator>(const optional<_Tp>&, const optional<_Tp>&)):
+ Turn into operator>(const optional<_Tp>&, const optional<_Up>&.
+ (operator<=(const optional<_Tp>&, const optional<_Tp>&)):
+ Turn into operator<=(const optional<_Tp>&, const optional<_Up>&).
+ (operator>=(const optional<_Tp>&, const optional<_Tp>&)):
+ Turn into operator>=(const optional<_Tp>&, const optional<_Up>&).
+ (operator==(const optional<_Tp>&, const _Tp&)):
+ Turn into operator==(const optional<_Tp>&, const _Up&).
+ (operator==(const _Tp&, const optional<_Tp>&)):
+ Turn into operator==(const _Up&, const optional<_Tp>&).
+ (operator!=(const optional<_Tp>&, const _Tp&)):
+ Turn into operator!=(const optional<_Tp>&, const _Up&).
+ (operator!=(const _Tp&, const optional<_Tp>&)):
+ Turn into operator!=(const _Up&, const optional<_Tp>&).
+ (operator<(const optional<_Tp>&, const _Tp&)):
+ Turn into operator<(const optional<_Tp>&, const _Up&).
+ (operator<(const _Tp&, const optional<_Tp>&)):
+ Turn into operator<(const _Up&, const optional<_Tp>&).
+ (operator>(const optional<_Tp>&, const _Tp&)):
+ Turn into operator>(const optional<_Tp>&, const _Up&).
+ (operator>(const _Tp&, const optional<_Tp>&)):
+ Turn into operator>(const _Up&, const optional<_Tp>&).
+ (operator<=(const optional<_Tp>&, const _Tp&)):
+ Turn into operator<=(const optional<_Tp>&, const _Up&).
+ (operator<=(const _Tp&, const optional<_Tp>&)):
+ Turn into operator<=(const _Up&, const optional<_Tp>&).
+ (operator>=(const optional<_Tp>&, const _Tp&)):
+ Turn into operator>=(const optional<_Tp>&, const _Up&).
+ (operator>=(const _Tp&, const optional<_Tp>&)):
+ Turn into operator>=(const _Up&, const optional<_Tp>&).
+ * testsuite/20_util/optional/relops/7.cc: New.
+
2017-03-10 Jonathan Wakely <jwakely@redhat.com>
* testsuite/17_intro/names.cc: Undefine macros that clash with
enable_if_t<is_convertible<_Tp, bool>::value, bool>;
// Comparisons between optional values.
- template<typename _Tp>
+ template<typename _Tp, typename _Up>
constexpr auto
- operator==(const optional<_Tp>& __lhs, const optional<_Tp>& __rhs)
- -> __optional_relop_t<decltype(declval<_Tp>() == declval<_Tp>())>
+ operator==(const optional<_Tp>& __lhs, const optional<_Up>& __rhs)
+ -> __optional_relop_t<decltype(declval<_Tp>() == declval<_Up>())>
{
return static_cast<bool>(__lhs) == static_cast<bool>(__rhs)
&& (!__lhs || *__lhs == *__rhs);
}
- template<typename _Tp>
+ template<typename _Tp, typename _Up>
constexpr auto
- operator!=(const optional<_Tp>& __lhs, const optional<_Tp>& __rhs)
- -> __optional_relop_t<decltype(declval<_Tp>() != declval<_Tp>())>
+ operator!=(const optional<_Tp>& __lhs, const optional<_Up>& __rhs)
+ -> __optional_relop_t<decltype(declval<_Tp>() != declval<_Up>())>
{
return static_cast<bool>(__lhs) != static_cast<bool>(__rhs)
|| (static_cast<bool>(__lhs) && *__lhs != *__rhs);
}
- template<typename _Tp>
+ template<typename _Tp, typename _Up>
constexpr auto
- operator<(const optional<_Tp>& __lhs, const optional<_Tp>& __rhs)
- -> __optional_relop_t<decltype(declval<_Tp>() < declval<_Tp>())>
+ operator<(const optional<_Tp>& __lhs, const optional<_Up>& __rhs)
+ -> __optional_relop_t<decltype(declval<_Tp>() < declval<_Up>())>
{
return static_cast<bool>(__rhs) && (!__lhs || *__lhs < *__rhs);
}
- template<typename _Tp>
+ template<typename _Tp, typename _Up>
constexpr auto
- operator>(const optional<_Tp>& __lhs, const optional<_Tp>& __rhs)
- -> __optional_relop_t<decltype(declval<_Tp>() > declval<_Tp>())>
+ operator>(const optional<_Tp>& __lhs, const optional<_Up>& __rhs)
+ -> __optional_relop_t<decltype(declval<_Tp>() > declval<_Up>())>
{
return static_cast<bool>(__lhs) && (!__rhs || *__lhs > *__rhs);
}
- template<typename _Tp>
+ template<typename _Tp, typename _Up>
constexpr auto
- operator<=(const optional<_Tp>& __lhs, const optional<_Tp>& __rhs)
- -> __optional_relop_t<decltype(declval<_Tp>() <= declval<_Tp>())>
+ operator<=(const optional<_Tp>& __lhs, const optional<_Up>& __rhs)
+ -> __optional_relop_t<decltype(declval<_Tp>() <= declval<_Up>())>
{
return !__lhs || (static_cast<bool>(__rhs) && *__lhs <= *__rhs);
}
- template<typename _Tp>
+ template<typename _Tp, typename _Up>
constexpr auto
- operator>=(const optional<_Tp>& __lhs, const optional<_Tp>& __rhs)
- -> __optional_relop_t<decltype(declval<_Tp>() >= declval<_Tp>())>
+ operator>=(const optional<_Tp>& __lhs, const optional<_Up>& __rhs)
+ -> __optional_relop_t<decltype(declval<_Tp>() >= declval<_Up>())>
{
return !__rhs || (static_cast<bool>(__lhs) && *__lhs >= *__rhs);
}
{ return !__rhs; }
// Comparisons with value type.
- template<typename _Tp>
+ template<typename _Tp, typename _Up>
constexpr auto
- operator==(const optional<_Tp>& __lhs, const _Tp& __rhs)
- -> __optional_relop_t<decltype(declval<_Tp>() == declval<_Tp>())>
+ operator==(const optional<_Tp>& __lhs, const _Up& __rhs)
+ -> __optional_relop_t<decltype(declval<_Tp>() == declval<_Up>())>
{ return __lhs && *__lhs == __rhs; }
- template<typename _Tp>
+ template<typename _Tp, typename _Up>
constexpr auto
- operator==(const _Tp& __lhs, const optional<_Tp>& __rhs)
- -> __optional_relop_t<decltype(declval<_Tp>() == declval<_Tp>())>
+ operator==(const _Up& __lhs, const optional<_Tp>& __rhs)
+ -> __optional_relop_t<decltype(declval<_Up>() == declval<_Tp>())>
{ return __rhs && __lhs == *__rhs; }
- template<typename _Tp>
+ template<typename _Tp, typename _Up>
constexpr auto
- operator!=(const optional<_Tp>& __lhs, const _Tp& __rhs)
- -> __optional_relop_t<decltype(declval<_Tp>() != declval<_Tp>())>
+ operator!=(const optional<_Tp>& __lhs, const _Up& __rhs)
+ -> __optional_relop_t<decltype(declval<_Tp>() != declval<_Up>())>
{ return !__lhs || *__lhs != __rhs; }
- template<typename _Tp>
+ template<typename _Tp, typename _Up>
constexpr auto
- operator!=(const _Tp& __lhs, const optional<_Tp>& __rhs)
- -> __optional_relop_t<decltype(declval<_Tp>() != declval<_Tp>())>
+ operator!=(const _Up& __lhs, const optional<_Tp>& __rhs)
+ -> __optional_relop_t<decltype(declval<_Up>() != declval<_Tp>())>
{ return !__rhs || __lhs != *__rhs; }
- template<typename _Tp>
+ template<typename _Tp, typename _Up>
constexpr auto
- operator<(const optional<_Tp>& __lhs, const _Tp& __rhs)
- -> __optional_relop_t<decltype(declval<_Tp>() < declval<_Tp>())>
+ operator<(const optional<_Tp>& __lhs, const _Up& __rhs)
+ -> __optional_relop_t<decltype(declval<_Tp>() < declval<_Up>())>
{ return !__lhs || *__lhs < __rhs; }
- template<typename _Tp>
+ template<typename _Tp, typename _Up>
constexpr auto
- operator<(const _Tp& __lhs, const optional<_Tp>& __rhs)
- -> __optional_relop_t<decltype(declval<_Tp>() < declval<_Tp>())>
+ operator<(const _Up& __lhs, const optional<_Tp>& __rhs)
+ -> __optional_relop_t<decltype(declval<_Up>() < declval<_Tp>())>
{ return __rhs && __lhs < *__rhs; }
- template<typename _Tp>
+ template<typename _Tp, typename _Up>
constexpr auto
- operator>(const optional<_Tp>& __lhs, const _Tp& __rhs)
- -> __optional_relop_t<decltype(declval<_Tp>() > declval<_Tp>())>
+ operator>(const optional<_Tp>& __lhs, const _Up& __rhs)
+ -> __optional_relop_t<decltype(declval<_Tp>() > declval<_Up>())>
{ return __lhs && *__lhs > __rhs; }
- template<typename _Tp>
+ template<typename _Tp, typename _Up>
constexpr auto
- operator>(const _Tp& __lhs, const optional<_Tp>& __rhs)
- -> __optional_relop_t<decltype(declval<_Tp>() > declval<_Tp>())>
+ operator>(const _Up& __lhs, const optional<_Tp>& __rhs)
+ -> __optional_relop_t<decltype(declval<_Up>() > declval<_Tp>())>
{ return !__rhs || __lhs > *__rhs; }
- template<typename _Tp>
+ template<typename _Tp, typename _Up>
constexpr auto
- operator<=(const optional<_Tp>& __lhs, const _Tp& __rhs)
- -> __optional_relop_t<decltype(declval<_Tp>() <= declval<_Tp>())>
+ operator<=(const optional<_Tp>& __lhs, const _Up& __rhs)
+ -> __optional_relop_t<decltype(declval<_Tp>() <= declval<_Up>())>
{ return !__lhs || *__lhs <= __rhs; }
- template<typename _Tp>
+ template<typename _Tp, typename _Up>
constexpr auto
- operator<=(const _Tp& __lhs, const optional<_Tp>& __rhs)
- -> __optional_relop_t<decltype(declval<_Tp>() <= declval<_Tp>())>
+ operator<=(const _Up& __lhs, const optional<_Tp>& __rhs)
+ -> __optional_relop_t<decltype(declval<_Up>() <= declval<_Tp>())>
{ return __rhs && __lhs <= *__rhs; }
- template<typename _Tp>
+ template<typename _Tp, typename _Up>
constexpr auto
- operator>=(const optional<_Tp>& __lhs, const _Tp& __rhs)
- -> __optional_relop_t<decltype(declval<_Tp>() >= declval<_Tp>())>
+ operator>=(const optional<_Tp>& __lhs, const _Up& __rhs)
+ -> __optional_relop_t<decltype(declval<_Tp>() >= declval<_Up>())>
{ return __lhs && *__lhs >= __rhs; }
- template<typename _Tp>
+ template<typename _Tp, typename _Up>
constexpr auto
- operator>=(const _Tp& __lhs, const optional<_Tp>& __rhs)
- -> __optional_relop_t<decltype(declval<_Tp>() >= declval<_Tp>())>
+ operator>=(const _Up& __lhs, const optional<_Tp>& __rhs)
+ -> __optional_relop_t<decltype(declval<_Up>() >= declval<_Tp>())>
{ return !__rhs || __lhs >= *__rhs; }
// Swap and creation functions.