Skip to content

Commit

Permalink
geometry.h: workaround for consistent comparisons from C++20
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekotekina committed Feb 10, 2020
1 parent 6e47a6f commit 9ea1f65
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions Utilities/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,18 @@ struct size2_base
return *this;
}

constexpr bool operator == (const size2_base& rhs) const
constexpr bool operator ==(const size2_base& rhs) const
{
return width == rhs.width && height == rhs.height;
}

constexpr bool operator != (const size2_base& rhs) const
#if __cpp_impl_three_way_comparison >= 201711
#else
constexpr bool operator !=(const size2_base& rhs) const
{
return width != rhs.width || height != rhs.height;
}
#endif

template<typename NT>
constexpr operator size2_base<NT>() const
Expand Down Expand Up @@ -644,10 +647,13 @@ struct coord_base
return position == rhs.position && size == rhs.size;
}

#if __cpp_impl_three_way_comparison >= 201711
#else
constexpr bool operator != (const coord_base& rhs) const
{
return position != rhs.position || size != rhs.size;
}
#endif

template<typename NT>
constexpr operator coord_base<NT>() const
Expand Down Expand Up @@ -876,11 +882,13 @@ struct color4_base
{
return r == rhs.r && g == rhs.g && b == rhs.b && a == rhs.a;
}

#if __cpp_impl_three_way_comparison >= 201711
#else
constexpr bool operator != (const color4_base& rhs) const
{
return !(*this == rhs);
}
#endif

void operator *= (const color4_base<T>& rhs)
{
Expand Down Expand Up @@ -950,11 +958,13 @@ struct color3_base
{
return r == rhs.r && g == rhs.g && b == rhs.b;
}

#if __cpp_impl_three_way_comparison >= 201711
#else
constexpr bool operator != (const color3_base& rhs) const
{
return !(*this == rhs);
}
#endif

template<typename NT>
constexpr operator color3_base<NT>() const
Expand Down Expand Up @@ -993,10 +1003,13 @@ struct color2_base
return r == rhs.r && g == rhs.g;
}

#if __cpp_impl_three_way_comparison >= 201711
#else
constexpr bool operator != (const color2_base& rhs) const
{
return !(*this == rhs);
}
#endif

template<typename NT>
constexpr operator color2_base<NT>() const
Expand Down Expand Up @@ -1024,10 +1037,13 @@ struct color1_base
return r == rhs.r;
}

#if __cpp_impl_three_way_comparison >= 201711
#else
constexpr bool operator != (const color1_base& rhs) const
{
return !(*this == rhs);
}
#endif

template<typename NT>
constexpr operator color1_base<NT>() const
Expand Down

0 comments on commit 9ea1f65

Please sign in to comment.