[RFC,v2,7/7] libcamera: base: span: Deprecate it
diff mbox series

Message ID 20260323102724.1385487-8-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • C++20 migration
Related show

Commit Message

Barnabás Pőcze March 23, 2026, 10:27 a.m. UTC
With the switch to C++20, this type has largely become unnecessary,
but since users might still depend on it, do not remove it yet, only
deprecate it. The tests are also kept for now.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 include/libcamera/base/span.h | 4 ++--
 test/span.cpp                 | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

Comments

Laurent Pinchart March 26, 2026, 3:15 p.m. UTC | #1
On Mon, Mar 23, 2026 at 11:27:24AM +0100, Barnabás Pőcze wrote:
> With the switch to C++20, this type has largely become unnecessary,
> but since users might still depend on it, do not remove it yet, only
> deprecate it. The tests are also kept for now.

This seems reasonable. We could drop the tests already as the Span class
shouldn't be touched any more, but it doesn't hurt keeping them until we
drop span.h.

Do you have a timeline in mind for removing the header completely ?

> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  include/libcamera/base/span.h | 4 ++--
>  test/span.cpp                 | 1 +
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/include/libcamera/base/span.h b/include/libcamera/base/span.h
> index 5c7a98d8e..c8da7cfd1 100644
> --- a/include/libcamera/base/span.h
> +++ b/include/libcamera/base/span.h
> @@ -86,7 +86,7 @@ struct tuple_size<Span<T, dynamic_extent>>;
>  } /* namespace utils */
>  
>  template<typename T, std::size_t Extent>
> -class Span
> +class [[deprecated("Use `std::span` instead")]] Span
>  {
>  public:
>  	using element_type = T;
> @@ -256,7 +256,7 @@ private:
>  };
>  
>  template<typename T>
> -class Span<T, dynamic_extent>
> +class [[deprecated("Use `std::span` instead")]] Span<T, dynamic_extent>
>  {
>  public:
>  	using element_type = T;
> diff --git a/test/span.cpp b/test/span.cpp
> index 4b9f3279a..56b29512f 100644
> --- a/test/span.cpp
> +++ b/test/span.cpp
> @@ -9,6 +9,7 @@
>   * Include first to ensure the header is self-contained, as there's no span.cpp
>   * in libcamera.
>   */
> +#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
>  #include <libcamera/base/span.h>
>  
>  #include <array>
Barnabás Pőcze March 27, 2026, 8:28 a.m. UTC | #2
2026. 03. 26. 16:15 keltezéssel, Laurent Pinchart írta:
> On Mon, Mar 23, 2026 at 11:27:24AM +0100, Barnabás Pőcze wrote:
>> With the switch to C++20, this type has largely become unnecessary,
>> but since users might still depend on it, do not remove it yet, only
>> deprecate it. The tests are also kept for now.
> 
> This seems reasonable. We could drop the tests already as the Span class
> shouldn't be touched any more, but it doesn't hurt keeping them until we
> drop span.h.
> 
> Do you have a timeline in mind for removing the header completely ?

Not sure, first gcc 9 support needs to be dropped, then I think having one or two
releases with the deprecation is reasonable.


> 
>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
>> ---
>>   include/libcamera/base/span.h | 4 ++--
>>   test/span.cpp                 | 1 +
>>   2 files changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/libcamera/base/span.h b/include/libcamera/base/span.h
>> index 5c7a98d8e..c8da7cfd1 100644
>> --- a/include/libcamera/base/span.h
>> +++ b/include/libcamera/base/span.h
>> @@ -86,7 +86,7 @@ struct tuple_size<Span<T, dynamic_extent>>;
>>   } /* namespace utils */
>>   
>>   template<typename T, std::size_t Extent>
>> -class Span
>> +class [[deprecated("Use `std::span` instead")]] Span
>>   {
>>   public:
>>   	using element_type = T;
>> @@ -256,7 +256,7 @@ private:
>>   };
>>   
>>   template<typename T>
>> -class Span<T, dynamic_extent>
>> +class [[deprecated("Use `std::span` instead")]] Span<T, dynamic_extent>
>>   {
>>   public:
>>   	using element_type = T;
>> diff --git a/test/span.cpp b/test/span.cpp
>> index 4b9f3279a..56b29512f 100644
>> --- a/test/span.cpp
>> +++ b/test/span.cpp
>> @@ -9,6 +9,7 @@
>>    * Include first to ensure the header is self-contained, as there's no span.cpp
>>    * in libcamera.
>>    */
>> +#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
>>   #include <libcamera/base/span.h>
>>   
>>   #include <array>
>
Laurent Pinchart March 27, 2026, 8:35 a.m. UTC | #3
On Fri, Mar 27, 2026 at 09:28:44AM +0100, Barnabás Pőcze wrote:
> 2026. 03. 26. 16:15 keltezéssel, Laurent Pinchart írta:
> > On Mon, Mar 23, 2026 at 11:27:24AM +0100, Barnabás Pőcze wrote:
> >> With the switch to C++20, this type has largely become unnecessary,
> >> but since users might still depend on it, do not remove it yet, only
> >> deprecate it. The tests are also kept for now.
> > 
> > This seems reasonable. We could drop the tests already as the Span class
> > shouldn't be touched any more, but it doesn't hurt keeping them until we
> > drop span.h.
> > 
> > Do you have a timeline in mind for removing the header completely ?
> 
> Not sure, first gcc 9 support needs to be dropped, then I think having one or two
> releases with the deprecation is reasonable.

Sounds good to me, thanks.

> >> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> > 
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > 
> >> ---
> >>   include/libcamera/base/span.h | 4 ++--
> >>   test/span.cpp                 | 1 +
> >>   2 files changed, 3 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/include/libcamera/base/span.h b/include/libcamera/base/span.h
> >> index 5c7a98d8e..c8da7cfd1 100644
> >> --- a/include/libcamera/base/span.h
> >> +++ b/include/libcamera/base/span.h
> >> @@ -86,7 +86,7 @@ struct tuple_size<Span<T, dynamic_extent>>;
> >>   } /* namespace utils */
> >>   
> >>   template<typename T, std::size_t Extent>
> >> -class Span
> >> +class [[deprecated("Use `std::span` instead")]] Span
> >>   {
> >>   public:
> >>   	using element_type = T;
> >> @@ -256,7 +256,7 @@ private:
> >>   };
> >>   
> >>   template<typename T>
> >> -class Span<T, dynamic_extent>
> >> +class [[deprecated("Use `std::span` instead")]] Span<T, dynamic_extent>
> >>   {
> >>   public:
> >>   	using element_type = T;
> >> diff --git a/test/span.cpp b/test/span.cpp
> >> index 4b9f3279a..56b29512f 100644
> >> --- a/test/span.cpp
> >> +++ b/test/span.cpp
> >> @@ -9,6 +9,7 @@
> >>    * Include first to ensure the header is self-contained, as there's no span.cpp
> >>    * in libcamera.
> >>    */
> >> +#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
> >>   #include <libcamera/base/span.h>
> >>   
> >>   #include <array>

Patch
diff mbox series

diff --git a/include/libcamera/base/span.h b/include/libcamera/base/span.h
index 5c7a98d8e..c8da7cfd1 100644
--- a/include/libcamera/base/span.h
+++ b/include/libcamera/base/span.h
@@ -86,7 +86,7 @@  struct tuple_size<Span<T, dynamic_extent>>;
 } /* namespace utils */
 
 template<typename T, std::size_t Extent>
-class Span
+class [[deprecated("Use `std::span` instead")]] Span
 {
 public:
 	using element_type = T;
@@ -256,7 +256,7 @@  private:
 };
 
 template<typename T>
-class Span<T, dynamic_extent>
+class [[deprecated("Use `std::span` instead")]] Span<T, dynamic_extent>
 {
 public:
 	using element_type = T;
diff --git a/test/span.cpp b/test/span.cpp
index 4b9f3279a..56b29512f 100644
--- a/test/span.cpp
+++ b/test/span.cpp
@@ -9,6 +9,7 @@ 
  * Include first to ensure the header is self-contained, as there's no span.cpp
  * in libcamera.
  */
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 #include <libcamera/base/span.h>
 
 #include <array>