Commit 10986dd6 authored by Michaël Roynard's avatar Michaël Roynard
Browse files

Fix pixel_adaptor concept comparison operators

parent 7c1fb134
......@@ -39,13 +39,17 @@ namespace mln::details
point_type m_point;
};
template <class T, std::size_t N>
template <class T, std::size_t N,
typename = std::void_t<decltype(std::declval<typename ndpix_base<T, N>::reference>() ==
std::declval<typename ndpix_base<T, N>::reference>())>>
bool operator==(const ndpix_base<T, N>& lhs, const ndpix_base<T, N>& rhs)
{
return lhs.val() == rhs.val() && lhs.point() == rhs.point();
}
template <class T, std::size_t N>
template <class T, std::size_t N,
typename = std::void_t<decltype(std::declval<typename ndpix_base<T, N>::reference>() !=
std::declval<typename ndpix_base<T, N>::reference>())>>
bool operator!=(const ndpix_base<T, N>& lhs, const ndpix_base<T, N>& rhs)
{
return !(lhs == rhs);
......@@ -81,13 +85,15 @@ namespace mln::details
bool equal(const ndpix& other) const { return this->m_point[N - 1] == other.m_point[N - 1]; }
};
template <class T, std::size_t N>
template <class T, std::size_t N,
typename = std::void_t<decltype(std::declval<ndpix<T, N>>().val() == std::declval<ndpix<T, N>>().val())>>
bool operator==(const ndpix<T, N>& lhs, const ndpix<T, N>& rhs)
{
return lhs.val() == rhs.val() && lhs.point() == rhs.point();
}
template <class T, std::size_t N>
template <class T, std::size_t N,
typename = std::void_t<decltype(std::declval<ndpix<T, N>>().val() != std::declval<ndpix<T, N>>().val())>>
bool operator!=(const ndpix<T, N>& lhs, const ndpix<T, N>& rhs)
{
return !(lhs == rhs);
......
......@@ -24,7 +24,7 @@ namespace mln
void advance(point_type p) { m_pix.advance(p); }
pixel_adaptor() = default;
pixel_adaptor(Pixel px)
explicit pixel_adaptor(Pixel px)
: m_pix{std::move(px)}
{
}
......@@ -35,22 +35,40 @@ namespace mln
private:
Pixel m_pix;
/*
public:
template <class LhsPix, class PixRhs>
friend bool operator==(const pixel_adaptor<LhsPix>& lhs, const pixel_adaptor<PixRhs>& rhs)
{
return lhs.base() == rhs.base();
}
template <class Pix>
friend bool operator!=(const pixel_adaptor<Pix>& lhs, const pixel_adaptor<Pix>& rhs)
{
return !(lhs == rhs);
}
*/
};
template <class LhsPix, class RhsPix,
typename = std::void_t<decltype(std::declval<typename pixel_adaptor<LhsPix>::reference>() ==
std::declval<typename RhsPix::reference>())>>
bool operator==(const pixel_adaptor<LhsPix>& lhs, const RhsPix& rhs)
{
return lhs.val() == rhs.val() && lhs.point() == rhs.point();
}
template <class LhsPix, class RhsPix,
typename = std::void_t<decltype(std::declval<typename RhsPix::reference>() ==
std::declval<typename pixel_adaptor<LhsPix>::reference>())>>
bool operator==(const LhsPix& lhs, const pixel_adaptor<RhsPix>& rhs)
{
return rhs == lhs;
}
template <class LhsPix, class RhsPix,
typename = std::void_t<decltype(std::declval<typename pixel_adaptor<LhsPix>::reference>() !=
std::declval<typename RhsPix::reference>())>>
bool operator!=(const pixel_adaptor<LhsPix>& lhs, const RhsPix& rhs)
{
return !(lhs == rhs);
}
template <class LhsPix, class RhsPix,
typename = std::void_t<decltype(std::declval<typename RhsPix::reference>() !=
std::declval<typename pixel_adaptor<LhsPix>::reference>())>>
bool operator!=(const LhsPix& lhs, const pixel_adaptor<RhsPix>& rhs)
{
return !(rhs == lhs);
}
namespace detail
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment