Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions indirect.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,9 @@ class indirect {
//

template <class U, class AA>
[[nodiscard]] friend constexpr bool operator==(const indirect<T, A>& lhs,
const indirect<U, AA>& rhs) {
[[nodiscard]] friend constexpr bool operator==(
const indirect<T, A>& lhs,
const indirect<U, AA>& rhs) noexcept(noexcept(*lhs == *rhs)) {
if (lhs.valueless_after_move()) {
return rhs.valueless_after_move();
}
Expand All @@ -387,8 +388,8 @@ class indirect {
}

template <class U>
[[nodiscard]] friend constexpr bool operator==(const indirect<T, A>& lhs,
const U& rhs)
[[nodiscard]] friend constexpr bool operator==(
const indirect<T, A>& lhs, const U& rhs) noexcept(noexcept(*lhs == rhs))
requires(!is_indirect_v<U>)
{
if (lhs.valueless_after_move()) {
Expand Down
72 changes: 44 additions & 28 deletions indirect_cxx14.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,53 +373,59 @@ class indirect : private detail::empty_base_optimization<A> {
}

template <class U, class AA>
[[nodiscard]] friend bool operator==(const indirect<T, A>& lhs,
const indirect<U, AA>& rhs) {
[[nodiscard]] friend bool operator==(
const indirect<T, A>& lhs,
const indirect<U, AA>& rhs) noexcept(noexcept(*lhs == *rhs)) {
if (lhs.valueless_after_move() || rhs.valueless_after_move()) {
return lhs.valueless_after_move() && rhs.valueless_after_move();
}
return *lhs == *rhs;
}

template <class U, class AA>
[[nodiscard]] friend bool operator!=(const indirect<T, A>& lhs,
const indirect<U, AA>& rhs) {
[[nodiscard]] friend bool operator!=(
const indirect<T, A>& lhs,
const indirect<U, AA>& rhs) noexcept(noexcept(*lhs != *rhs)) {
if (lhs.valueless_after_move() || rhs.valueless_after_move()) {
return !(lhs.valueless_after_move() && rhs.valueless_after_move());
}
return *lhs != *rhs;
}

template <class U, class AA>
[[nodiscard]] friend bool operator<(const indirect<T, A>& lhs,
const indirect<U, AA>& rhs) {
[[nodiscard]] friend bool operator<(
const indirect<T, A>& lhs,
const indirect<U, AA>& rhs) noexcept(noexcept(*lhs < *rhs)) {
if (lhs.valueless_after_move()) {
return !rhs.valueless_after_move();
}
return !rhs.valueless_after_move() && *lhs < *rhs;
}

template <class U, class AA>
[[nodiscard]] friend bool operator>(const indirect<T, A>& lhs,
const indirect<U, AA>& rhs) {
[[nodiscard]] friend bool operator>(
const indirect<T, A>& lhs,
const indirect<U, AA>& rhs) noexcept(noexcept(*lhs > *rhs)) {
if (rhs.valueless_after_move()) {
return !lhs.valueless_after_move();
}
return !lhs.valueless_after_move() && *lhs > *rhs;
}

template <class U, class AA>
[[nodiscard]] friend bool operator<=(const indirect<T, A>& lhs,
const indirect<U, AA>& rhs) {
[[nodiscard]] friend bool operator<=(
const indirect<T, A>& lhs,
const indirect<U, AA>& rhs) noexcept(noexcept(*lhs <= *rhs)) {
if (lhs.valueless_after_move()) {
return true;
}
return !rhs.valueless_after_move() && *lhs <= *rhs;
}

template <class U, class AA>
[[nodiscard]] friend bool operator>=(const indirect<T, A>& lhs,
const indirect<U, AA>& rhs) {
[[nodiscard]] friend bool operator>=(
const indirect<T, A>& lhs,
const indirect<U, AA>& rhs) noexcept(noexcept(*lhs >= *rhs)) {
if (rhs.valueless_after_move()) {
return true;
}
Expand All @@ -430,7 +436,8 @@ class indirect : private detail::empty_base_optimization<A> {
template <class U,
typename std::enable_if<!is_indirect<U>::value, int>::type = 0>
[[nodiscard]] friend bool operator==(const indirect<T, A>& lhs,
const U& rhs) {
const U& rhs) noexcept(noexcept(*lhs ==
rhs)) {
if (lhs.valueless_after_move()) {
return false;
}
Expand All @@ -439,8 +446,8 @@ class indirect : private detail::empty_base_optimization<A> {

template <class U,
typename std::enable_if<!is_indirect<U>::value, int>::type = 0>
[[nodiscard]] friend bool operator==(const U& lhs,
const indirect<T, A>& rhs) {
[[nodiscard]] friend bool operator==(
const U& lhs, const indirect<T, A>& rhs) noexcept(noexcept(lhs == *rhs)) {
if (rhs.valueless_after_move()) {
return false;
}
Expand All @@ -450,7 +457,8 @@ class indirect : private detail::empty_base_optimization<A> {
template <class U,
typename std::enable_if<!is_indirect<U>::value, int>::type = 0>
[[nodiscard]] friend bool operator!=(const indirect<T, A>& lhs,
const U& rhs) {
const U& rhs) noexcept(noexcept(*lhs !=
rhs)) {
if (lhs.valueless_after_move()) {
return true;
}
Expand All @@ -459,8 +467,8 @@ class indirect : private detail::empty_base_optimization<A> {

template <class U,
typename std::enable_if<!is_indirect<U>::value, int>::type = 0>
[[nodiscard]] friend bool operator!=(const U& lhs,
const indirect<T, A>& rhs) {
[[nodiscard]] friend bool operator!=(
const U& lhs, const indirect<T, A>& rhs) noexcept(noexcept(lhs != *rhs)) {
if (rhs.valueless_after_move()) {
return true;
}
Expand All @@ -469,7 +477,9 @@ class indirect : private detail::empty_base_optimization<A> {

template <class U,
typename std::enable_if<!is_indirect<U>::value, int>::type = 0>
[[nodiscard]] friend bool operator<(const indirect<T, A>& lhs, const U& rhs) {
[[nodiscard]] friend bool operator<(const indirect<T, A>& lhs,
const U& rhs) noexcept(noexcept(*lhs <
rhs)) {
if (lhs.valueless_after_move()) {
return true;
}
Expand All @@ -478,7 +488,8 @@ class indirect : private detail::empty_base_optimization<A> {

template <class U,
typename std::enable_if<!is_indirect<U>::value, int>::type = 0>
[[nodiscard]] friend bool operator<(const U& lhs, const indirect<T, A>& rhs) {
[[nodiscard]] friend bool operator<(
const U& lhs, const indirect<T, A>& rhs) noexcept(noexcept(lhs < *rhs)) {
if (rhs.valueless_after_move()) {
return false;
}
Expand All @@ -487,7 +498,9 @@ class indirect : private detail::empty_base_optimization<A> {

template <class U,
typename std::enable_if<!is_indirect<U>::value, int>::type = 0>
[[nodiscard]] friend bool operator>(const indirect<T, A>& lhs, const U& rhs) {
[[nodiscard]] friend bool operator>(const indirect<T, A>& lhs,
const U& rhs) noexcept(noexcept(*lhs >
rhs)) {
if (lhs.valueless_after_move()) {
return false;
}
Expand All @@ -496,7 +509,8 @@ class indirect : private detail::empty_base_optimization<A> {

template <class U,
typename std::enable_if<!is_indirect<U>::value, int>::type = 0>
[[nodiscard]] friend bool operator>(const U& lhs, const indirect<T, A>& rhs) {
[[nodiscard]] friend bool operator>(
const U& lhs, const indirect<T, A>& rhs) noexcept(noexcept(lhs > *rhs)) {
if (rhs.valueless_after_move()) {
return true;
}
Expand All @@ -506,7 +520,8 @@ class indirect : private detail::empty_base_optimization<A> {
template <class U,
typename std::enable_if<!is_indirect<U>::value, int>::type = 0>
[[nodiscard]] friend bool operator<=(const indirect<T, A>& lhs,
const U& rhs) {
const U& rhs) noexcept(noexcept(*lhs <=
rhs)) {
if (lhs.valueless_after_move()) {
return true;
}
Expand All @@ -515,8 +530,8 @@ class indirect : private detail::empty_base_optimization<A> {

template <class U,
typename std::enable_if<!is_indirect<U>::value, int>::type = 0>
[[nodiscard]] friend bool operator<=(const U& lhs,
const indirect<T, A>& rhs) {
[[nodiscard]] friend bool operator<=(
const U& lhs, const indirect<T, A>& rhs) noexcept(noexcept(lhs <= *rhs)) {
if (rhs.valueless_after_move()) {
return false;
}
Expand All @@ -526,7 +541,8 @@ class indirect : private detail::empty_base_optimization<A> {
template <class U,
typename std::enable_if<!is_indirect<U>::value, int>::type = 0>
[[nodiscard]] friend bool operator>=(const indirect<T, A>& lhs,
const U& rhs) {
const U& rhs) noexcept(noexcept(*lhs >=
rhs)) {
if (lhs.valueless_after_move()) {
return false;
}
Expand All @@ -535,8 +551,8 @@ class indirect : private detail::empty_base_optimization<A> {

template <class U,
typename std::enable_if<!is_indirect<U>::value, int>::type = 0>
[[nodiscard]] friend bool operator>=(const U& lhs,
const indirect<T, A>& rhs) {
[[nodiscard]] friend bool operator>=(
const U& lhs, const indirect<T, A>& rhs) noexcept(noexcept(lhs >= *rhs)) {
if (rhs.valueless_after_move()) {
return true;
}
Expand Down
Loading