[v1,2/2] libcamera: base: span: Deprecate it
diff mbox series

Message ID 20260825123412.837696-3-barnabas.pocze@ideasonboard.com
State Superseded
Headers show
Series
  • treewide: Use `std::span`
Related show

Commit Message

Barnabás Pőcze Aug. 25, 2026, 12:34 p.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>
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(-)

Comments

Kieran Bingham Aug. 28, 2026, 10:39 a.m. UTC | #1
Quoting Barnabás Pőcze (2026-08-25 13:34:12)
> 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>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Back in RFC time I asked if we should do something like:

      > > Can we in anyway 'alias' std::span to libcamera::Span for gcc-9, so we
      > > could already move forwards ? or would that get too messy ?
      >
      > I am a bit worried it would create more issues than it solves.

      Ok, don't worry then.

Now that we don't have to support gcc-9 at all, What about the other way:

namespace libcamera {

template<typename T>
using Span [[deprecated("use std::span instead")]] = std::span<T>;

}

And then already drop the code ?

But either way I'm fine with this as it is:

Reviewed-by: Kieran Bingham <kieran.bingham@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 5c7a98d8e7..c8da7cfd1c 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 4b9f3279ad..56b29512f0 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>
> -- 
> 2.55.0
>
Barnabás Pőcze Aug. 31, 2026, 1:23 p.m. UTC | #2
2026. 08. 28. 12:39 keltezéssel, Kieran Bingham írta:
> Quoting Barnabás Pőcze (2026-08-25 13:34:12)
>> 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>
>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> Back in RFC time I asked if we should do something like:
> 
>        > > Can we in anyway 'alias' std::span to libcamera::Span for gcc-9, so we
>        > > could already move forwards ? or would that get too messy ?
>        >
>        > I am a bit worried it would create more issues than it solves.
> 
>        Ok, don't worry then.
> 
> Now that we don't have to support gcc-9 at all, What about the other way:
> 
> namespace libcamera {
> 
> template<typename T>
> using Span [[deprecated("use std::span instead")]] = std::span<T>;
> 
> }
> 
> And then already drop the code ?

I did so, please check the next version.


> 
> But either way I'm fine with this as it is:
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@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 5c7a98d8e7..c8da7cfd1c 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 4b9f3279ad..56b29512f0 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>
>> -- 
>> 2.55.0
>>

Patch
diff mbox series

diff --git a/include/libcamera/base/span.h b/include/libcamera/base/span.h
index 5c7a98d8e7..c8da7cfd1c 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 4b9f3279ad..56b29512f0 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>