[libcamera-devel] [PATCH v2 3/5] provide a default fixed-sized Span constructor
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Tue Apr 5 18:27:20 CEST 2022
Hi Christian,
Thank you for the patch.
On Tue, Apr 05, 2022 at 01:42:13AM +0100, Christian Rauch via libcamera-devel wrote:
> This allows to construct empty 0-fixed-sized Spans.
>
> Signed-off-by: Christian Rauch <Rauch.Christian at gmx.de>
> ---
> include/libcamera/base/span.h | 2 --
> include/libcamera/controls.h | 2 +-
> 2 files changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/include/libcamera/base/span.h b/include/libcamera/base/span.h
> index 88d2e3de..bff4c115 100644
> --- a/include/libcamera/base/span.h
> +++ b/include/libcamera/base/span.h
> @@ -105,8 +105,6 @@ public:
>
> static constexpr std::size_t extent = Extent;
>
> - template<bool Dependent = false,
> - typename = std::enable_if_t<Dependent || Extent == 0>>
The issue here is that the std::span class has this constraint ([1]):
This overload participates in overload resolution only if
extent == 0 || extent == std::dynamic_extent.
[1] https://en.cppreference.com/w/cpp/container/span/span
If we drop the constraint here, we will have an issue when switching to
std::span in the future. Is there a way we could achieve the result
you're aiming for without this change ?
> constexpr Span() noexcept
> : data_(nullptr)
> {
> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
> index 665bcac1..de8a7770 100644
> --- a/include/libcamera/controls.h
> +++ b/include/libcamera/controls.h
> @@ -167,7 +167,7 @@ public:
>
> using V = typename T::value_type;
> const V *value = reinterpret_cast<const V *>(data().data());
> - return { value, numElements_ };
> + return T{ value, numElements_ };
> }
>
> #ifndef __DOXYGEN__
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list