Pixel concepts (details)

Pixel

template<typename Pix>
concept Pixel
  1. Refines the template <typename T> Regular concept.
  2. Pix::value_type models the template <typename Val> Value concept, is non-const and is not a reference.
  3. Pix::point_type models the template <typename Pnt> Point concept.
  4. Pix::image_type models the template <typename Ima> Image concept.
  5. Pix is consistant with point_type, value_type and reference from image_type.
  6. Pix provide methods value, point and image.

Notation

using value_type = Pix::value_type
using point_type = Pix::point_type
using image_type = Pix::image_type
using reference = Pix::reference
Pix pix
Pix pix_cpy
const Pix cpix
const Pix t
const Pix u

Valid Expressions

Possible implementation

template<typename P, Pix = remove_cvref<P>>
concept Pixel = requires Regular<Pix> &&

                requires {
                    typename Pix::value_type;
                    typename Pix::point_type;
                    typename Pix::image_type;
                    typename Pix::reference;
                } &&

                Value<Pix::value_type> &&
                Point<Pix::point_type> &&
                Image<Pix::image_type> &&

                Same<Pix::value_type, Pix::image_type::value_type> &&
                Same<Pix::point_type, Pix::image_type::point_type> &&
                Same<Pix::reference, Pix::image_type::reference> &&

                !is_const_v<Pix::value_type> &&
                !is_reference_v<Pix::value_type> &&

                requires(const Pix cpix, Pix pix) {
                    { cpix.value() } -> const reference;
                    { cpix.point() } -> const point_type;
                    { cpix.image() } -> const image_type;
                    { pix.value() }  -> reference;
                    { pix.point() }  -> point_type;
                    { pix.image() }  -> image_type;
                };

TransformedPixel

template<typename ToPix, typename FromPix>
concept TransformedPixel
  1. Refines the template <typename Pix> Pixel concept.
  2. ToPix::from_pixel_type models the template <typename Pix> Pixel concept.

Possible implementation

template<   typename TP, typename FP,
            ToPix = remove_cvref<TP>, FromPix = remove_cvref<FP>>
concept TransformedPixel =  Pixel<ToPix> &&
                            Pixel<FromPix> &&

                            requires {
                                typename ToPix::from_pixel_type
                            } &&
                            Same<ToPix::from_pixel_type, FromPix>;

ProjectedPixel

template<typename ToPix, typename FromPix>
concept ProjectedPixel
  1. Refines the template <typename ToPix, typename FromPix> TransformedPixel concept.

Possible implementation

template<typename ToPix, typename FromPix, PPix = remove_cvref<ToPix>>
concept ProjectedPixel =    TransformedPixel<ToPix, FromPix>;

ZippedPixel

template<typename ZPix, typename ...FromPixs>
concept ZippedPixel
  1. Refines the template <typename Pix> Pixel concept.
  2. FromPixs... models the template <typename Pix> Pixel concept.
  3. Let ZPix::zipped_pixel_type_list be the list of types zipped.

Possible implementation

template <typename...>
struct basic_type_list {};

template<   typename ZP, typename... FromPixs,
            ZPix = remove_cvref<ZPix>>
concept ZippedPixel =
    Pixel<ZPix> &&
    Pixel<FromPixs>... &&

    requires {
        typename ZPix::zipped_pixel_type_list<FromPixs...>
    } &&

    ConvertibleTo<
        ZPix::zipped_pixel_type_list<FromPixs...>,
        basic_type_list<FromPixs...>>;