Commit 957ce6ef authored by Michaël Roynard's avatar Michaël Roynard
Browse files

Fix size_type vs index_type by relaxing concept for the moment.

ndimage models RawImage (propotype stride/data)
parent 3f3ecccc
Pipeline #12435 passed with stages
in 14 minutes and 1 second
......@@ -18,9 +18,9 @@ namespace mln::archetypes
struct Image
{
using new_pixel_type = Pixel;
using value_type = pixel_value_t<Pixel>;
using reference = pixel_reference_t<Pixel>;
using point_type = domain_point_t<Domain>;
using value_type = pixel_value_t<Pixel>;
using reference = pixel_reference_t<Pixel>;
using point_type = domain_point_t<Domain>;
using domain_type = Domain;
using category_type = forward_image_tag;
using concrete_type = Image;
......@@ -80,7 +80,7 @@ namespace mln::archetypes
struct OutputImage : Image
{
using new_pixel_type = OutputPixel;
using reference = pixel_reference_t<OutputPixel>;
using reference = pixel_reference_t<OutputPixel>;
struct OutputPixelRange final
......@@ -150,7 +150,7 @@ namespace mln::archetypes
struct OutputIndexableImage final : IndexableImage
{
using new_pixel_type = OutputPixel;
using reference = pixel_reference_t<OutputPixel>;
using reference = pixel_reference_t<OutputPixel>;
image_reference_t<OutputIndexableImage> operator[](image_index_t<OutputIndexableImage>) const;
image_reference_t<OutputIndexableImage> operator[](image_index_t<OutputIndexableImage>);
......@@ -194,7 +194,7 @@ namespace mln::archetypes
struct OutputAccessibleImage final : AccessibleImage
{
using new_pixel_type = OutputPixel;
using reference = pixel_reference_t<OutputPixel>;
using reference = pixel_reference_t<OutputPixel>;
image_reference_t<OutputAccessibleImage> operator()(image_point_t<OutputAccessibleImage>) const;
image_reference_t<OutputAccessibleImage> operator()(image_point_t<OutputAccessibleImage>);
......@@ -254,7 +254,7 @@ namespace mln::archetypes
struct OutputBidirectionalImage : BidirectionalImage
{
using new_pixel_type = OutputPixel;
using reference = pixel_reference_t<OutputPixel>;
using reference = pixel_reference_t<OutputPixel>;
struct OutputPixelRange
{
......@@ -314,7 +314,7 @@ namespace mln::archetypes
const image_value_t<RawImage>* data() const;
std::size_t strides(int) const;
std::ptrdiff_t strides(int) const;
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
......@@ -326,7 +326,7 @@ namespace mln::archetypes
struct OutputRawImage final : RawImage
{
using new_pixel_type = OutputPixel;
using reference = pixel_reference_t<OutputPixel>;
using reference = pixel_reference_t<OutputPixel>;
image_reference_t<OutputRawImage> operator[](image_index_t<OutputRawImage>) const;
image_reference_t<OutputRawImage> operator[](image_index_t<OutputRawImage>);
......
......@@ -190,7 +190,7 @@ namespace mln::concepts
stl::DerivedFrom<image_category_t<Ima>, raw_image_tag> &&
requires (Ima ima, const Ima cima, int dim) {
{ ima.data() } -> stl::ConvertibleTo<const image_value_t<Ima>*>&&;
{ cima.strides(dim) } -> std::size_t;
{ cima.strides(dim) } -> std::ptrdiff_t;
};
......
......@@ -10,7 +10,9 @@ namespace mln::concepts
#ifdef PYLENE_CONCEPT_TS_ENABLED
// Index
template<typename Idx>
concept Index = stl::SignedIntegral<Idx>;
// FIXME: switch to SignedIntegral when concept is consolidated
concept Index = /* stl::SignedIntegral<Idx>; */
stl::Integral<Idx>;
#endif // PYLENE_CONCEPT_TS_ENABLED
// clang-format on
......
......@@ -182,8 +182,9 @@ namespace mln
using difference_type[[deprecated]] = int;
/// \copydoc image::size_type
// FIXME: switch to signed when concept is consolidated
using size_type[[deprecated]] = unsigned;
using index_type = int;
using index_type = size_type;
using pointer = T*;
using const_pointer = const T*;
......@@ -251,11 +252,9 @@ namespace mln
/// \copydoc image::operator[](size_type i) const
[[deprecated]] reference operator[](size_type i);
reference operator[](index_type i);
/// \copydoc image::operator[](size_type i) const
[[deprecated]] const_reference operator[](size_type i) const;
reference operator[](index_type i) const;
/// \copydoc image::at(const site_type& p) const
[[deprecated]] reference at(const site_type& p);
......@@ -383,6 +382,9 @@ namespace mln
// As a Raw Image
const std::size_t* strides() const;
std::ptrdiff_t strides(int d) const;
const_pointer data() const;
pointer data();
int border() const { return m_border; }
// Specialized algorithm
......@@ -443,8 +445,8 @@ namespace mln
T* m_ptr_origin; ///< Pointer to the first element (pmin)
std::array<std::ptrdiff_t, dim> m_index_strides; ///< Strides in number of elements (including the border)
size_t m_index_first; ///< index of pmin
size_t m_index_last; ///< index of pmax-1
size_type m_index_first; ///< index of pmin
size_type m_index_last; ///< index of pmax-1
};
/******************************/
......
......@@ -10,25 +10,15 @@
namespace concepts = mln::concepts;
#ifdef PYLENE_CONCEPT_TS_ENABLED
template <concepts::AccessibleImage Ima>
void foo(Ima)
{
}
#endif // PYLENE_CONCEPT_TS_ENABLED
TEST(Core, Image_Image2D)
{
#ifdef PYLENE_CONCEPT_TS_ENABLED
foo(mln::image2d<int>{});
static_assert(concepts::Image<mln::image2d<int>>);
static_assert(concepts::IndexableImage<mln::image2d<int>>);
static_assert(concepts::AccessibleImage<mln::image2d<int>>);
static_assert(concepts::BidirectionalImage<mln::image2d<int>>);
// static_assert(concepts::RawImage<mln::image2d<int>>);
static_assert(concepts::RawImage<mln::image2d<int>>);
#endif // PYLENE_CONCEPT_TS_ENABLED
}
......@@ -36,6 +26,33 @@ TEST(Core, Image_Image2D)
TEST(Core, Image_Image3D)
{
#ifdef PYLENE_CONCEPT_TS_ENABLED
// static_assert(concepts::Image<mln::image3d<int>>);
static_assert(concepts::Image<mln::image3d<int>>);
static_assert(concepts::IndexableImage<mln::image3d<int>>);
static_assert(concepts::AccessibleImage<mln::image3d<int>>);
static_assert(concepts::BidirectionalImage<mln::image3d<int>>);
static_assert(concepts::RawImage<mln::image3d<int>>);
#endif // PYLENE_CONCEPT_TS_ENABLED
}
/*
#ifdef PYLENE_CONCEPT_TS_ENABLED
template <concepts::RawImage Ima>
void foo(Ima)
{
}
#endif // PYLENE_CONCEPT_TS_ENABLED
TEST(Core, Image_OutputImage2D)
{
#ifdef PYLENE_CONCEPT_TS_ENABLED
foo(mln::image2d<int>{});
static_assert(concepts::Image<mln::image2d<int>>);
static_assert(concepts::IndexableImage<mln::image2d<int>>);
static_assert(concepts::AccessibleImage<mln::image2d<int>>);
static_assert(concepts::BidirectionalImage<mln::image2d<int>>);
static_assert(concepts::RawImage<mln::image2d<int>>);
#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