Commit 81b24f37 authored by Michaël Roynard's avatar Michaël Roynard
Browse files

Relax Regular constraint to Semiregular on pixel concept

parent 10986dd6
Pipeline #12637 passed with stages
in 14 minutes and 39 seconds
......@@ -18,9 +18,6 @@ namespace mln::archetypes
reference val() const;
};
bool operator==(const Pixel& lhs, const Pixel& rhs);
bool operator!=(const Pixel& lhs, const Pixel& rhs);
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(mln::concepts::Pixel<Pixel>, "Pixel archetype does not model the Pixel concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
......
......@@ -18,7 +18,7 @@ namespace mln::concepts
// Pixel
template<typename Pix>
concept Pixel =
stl::Regular<Pix> &&
stl::Semiregular<Pix> &&
requires {
typename pixel_value_t<Pix>;
typename pixel_reference_t<Pix>;
......
......@@ -40,16 +40,16 @@ namespace mln::details
};
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>())>>
typename =
std::void_t<decltype(std::declval<ndpix_base<T, N>>().val() == std::declval<ndpix_base<T, N>>().val())>>
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,
typename = std::void_t<decltype(std::declval<typename ndpix_base<T, N>::reference>() !=
std::declval<typename ndpix_base<T, N>::reference>())>>
typename =
std::void_t<decltype(std::declval<ndpix_base<T, N>>().val() != std::declval<ndpix_base<T, N>>().val())>>
bool operator!=(const ndpix_base<T, N>& lhs, const ndpix_base<T, N>& rhs)
{
return !(lhs == rhs);
......
......@@ -24,7 +24,7 @@ namespace mln
void advance(point_type p) { m_pix.advance(p); }
pixel_adaptor() = default;
explicit pixel_adaptor(Pixel px)
pixel_adaptor(Pixel px)
: m_pix{std::move(px)}
{
}
......@@ -37,33 +37,30 @@ namespace mln
Pixel m_pix;
};
template <class LhsPix, class RhsPix,
typename = std::void_t<decltype(std::declval<typename pixel_adaptor<LhsPix>::reference>() ==
std::declval<typename RhsPix::reference>())>>
class = std::void_t<decltype(std::declval<pixel_adaptor<LhsPix>>().val() == std::declval<RhsPix>().val())>>
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>())>>
class = std::void_t<decltype(std::declval<RhsPix>().val() == std::declval<pixel_adaptor<LhsPix>>().val())>>
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>())>>
class = std::void_t<decltype(std::declval<pixel_adaptor<LhsPix>>().val() != std::declval<RhsPix>().val())>>
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>())>>
class = std::void_t<decltype(std::declval<RhsPix>().val() != std::declval<pixel_adaptor<LhsPix>>().val())>>
bool operator!=(const LhsPix& lhs, const pixel_adaptor<RhsPix>& rhs)
{
return !(rhs == lhs);
......@@ -157,8 +154,8 @@ namespace mln
/// Indexable-image related methods
/// \{
template <typename dummy = I>
std::enable_if_t<indexable::value, reference> operator[](image_index_t<dummy> i)
template <typename dummy = I, typename Ret = reference>
std::enable_if_t<indexable::value, Ret> operator[](image_index_t<dummy> i)
{
return m_ima[i];
}
......@@ -169,8 +166,8 @@ namespace mln
return m_ima.index_of_point(p);
}
template <typename dummy = I>
std::enable_if_t<indexable::value, point_type> point_at_index(image_index_t<dummy> i) const
template <typename dummy = I, typename Ret = point_type>
std::enable_if_t<indexable::value, Ret> point_at_index(image_index_t<dummy> i) const
{
return m_ima.point_at_index(i);
}
......@@ -212,14 +209,15 @@ namespace mln
/// Raw-image related methods
/// \{
template <typename Ret = decltype(std::declval<I>().data())>
std::enable_if_t<std::is_base_of_v<raw_image_tag, category_type>, Ret> data() const
template <typename dummy = I>
std::enable_if_t<std::is_base_of_v<raw_image_tag, category_type>, decltype(std::declval<dummy>().data())>
data() const
{
return m_ima.data();
}
template <typename Ret = decltype(std::declval<I>().data())>
std::enable_if_t<std::is_base_of_v<raw_image_tag, category_type>, Ret> data()
template <typename dummy = I>
std::enable_if_t<std::is_base_of_v<raw_image_tag, category_type>, decltype(std::declval<dummy>().data())> data()
{
return m_ima.data();
}
......
#include <mln/core/concept/new/archetype/image.hpp>
#include <mln/core/concept/new/archetype/pixel.hpp>
#include <mln/core/concept/new/pixels.hpp>
#include <mln/core/image/view/adaptor.hpp>
......@@ -8,18 +9,30 @@
namespace concepts = mln::concepts;
namespace archetypes = mln::archetypes;
TEST(Core, ViewAdaptor_Pixel)
{
#ifdef PYLENE_CONCEPT_TS_ENABLED
template <concepts::Pixel Pix>
void foo(Pix)
static_assert(concepts::Pixel<mln::pixel_adaptor<archetypes::Pixel>>);
#endif // PYLENE_CONCEPT_TS_ENABLED
}
/*
#ifdef PYLENE_CONCEPT_TS_ENABLED
template <concepts::Image Ima>
void foo(Ima)
{
}
#endif // PYLENE_CONCEPT_TS_ENABLED
TEST(Core, ViewAdaptor_Pixel)
*/
TEST(Core, ViewAdaptor_Image)
{
#ifdef PYLENE_CONCEPT_TS_ENABLED
// foo(mln::pixel_adaptor<archetypes::Pixel>{});
// static_assert(concepts::Pixel<mln::pixel_adaptor<archetypes::Pixel>>);
static_assert(concepts::Image<mln::image_adaptor<archetypes::Image>>);
// TODO: all image properties + output Image
// foo(mln::image_adaptor<archetypes::Image>{});
#endif // PYLENE_CONCEPT_TS_ENABLED
}
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