[libcamera-devel,v2,1/2] Revert "libcamera: span: Provide and use helper variable templates for type traits"
diff mbox series

Message ID 20210126130415.26849-2-jeanmichel.hautbois@ideasonboard.com
State Accepted
Commit 33bfe7b7ef68d6221ad340ad117815e30f8fe6aa
Headers show
Series
  • libcamera: revert C++17 specific code for public API
Related show

Commit Message

Jean-Michel Hautbois Jan. 26, 2021, 1:04 p.m. UTC
This reverts commit 8e42c2feb7ff7c350ffbbf97dd963dfd54e21faa.
---
 include/libcamera/controls.h | 12 ++++++------
 include/libcamera/span.h     | 22 ++++++++--------------
 2 files changed, 14 insertions(+), 20 deletions(-)

Comments

Laurent Pinchart Jan. 26, 2021, 9:22 p.m. UTC | #1
Hi Jean-Michel,

Thank you for the patch.

On Tue, Jan 26, 2021 at 02:04:14PM +0100, Jean-Michel Hautbois wrote:
> This reverts commit 8e42c2feb7ff7c350ffbbf97dd963dfd54e21faa.

Missing Signed-off-by. Same for the next patch. Could you provide them
in an e-mail reply ?

> ---
>  include/libcamera/controls.h | 12 ++++++------
>  include/libcamera/span.h     | 22 ++++++++--------------
>  2 files changed, 14 insertions(+), 20 deletions(-)
> 
> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
> index 3634dc43..dc549a92 100644
> --- a/include/libcamera/controls.h
> +++ b/include/libcamera/controls.h
> @@ -96,7 +96,7 @@ public:
>  	ControlValue();
>  
>  #ifndef __DOXYGEN__
> -	template<typename T, typename std::enable_if_t<!details::is_span_v<T> &&
> +	template<typename T, typename std::enable_if_t<!details::is_span<T>::value &&
>  						       details::control_type<T>::value &&
>  						       !std::is_same_v<std::string, std::remove_cv_t<T>>,
>  						       std::nullptr_t> = nullptr>
> @@ -107,7 +107,7 @@ public:
>  		    &value, 1, sizeof(T));
>  	}
>  
> -	template<typename T, typename std::enable_if_t<details::is_span_v<T> ||
> +	template<typename T, typename std::enable_if_t<details::is_span<T>::value ||
>  						       std::is_same_v<std::string, std::remove_cv_t<T>>,
>  						       std::nullptr_t> = nullptr>
>  #else
> @@ -141,7 +141,7 @@ public:
>  	}
>  
>  #ifndef __DOXYGEN__
> -	template<typename T, typename std::enable_if_t<!details::is_span_v<T> &&
> +	template<typename T, typename std::enable_if_t<!details::is_span<T>::value &&
>  						       !std::is_same_v<std::string, std::remove_cv_t<T>>,
>  						       std::nullptr_t> = nullptr>
>  	T get() const
> @@ -152,7 +152,7 @@ public:
>  		return *reinterpret_cast<const T *>(data().data());
>  	}
>  
> -	template<typename T, typename std::enable_if_t<details::is_span_v<T> ||
> +	template<typename T, typename std::enable_if_t<details::is_span<T>::value ||
>  						       std::is_same_v<std::string, std::remove_cv_t<T>>,
>  						       std::nullptr_t> = nullptr>
>  #else
> @@ -169,7 +169,7 @@ public:
>  	}
>  
>  #ifndef __DOXYGEN__
> -	template<typename T, typename std::enable_if_t<!details::is_span_v<T> &&
> +	template<typename T, typename std::enable_if_t<!details::is_span<T>::value &&
>  						       !std::is_same_v<std::string, std::remove_cv_t<T>>,
>  						       std::nullptr_t> = nullptr>
>  	void set(const T &value)
> @@ -178,7 +178,7 @@ public:
>  		    reinterpret_cast<const void *>(&value), 1, sizeof(T));
>  	}
>  
> -	template<typename T, typename std::enable_if_t<details::is_span_v<T> ||
> +	template<typename T, typename std::enable_if_t<details::is_span<T>::value ||
>  						       std::is_same_v<std::string, std::remove_cv_t<T>>,
>  						       std::nullptr_t> = nullptr>
>  #else
> diff --git a/include/libcamera/span.h b/include/libcamera/span.h
> index e7ffef12..d720adb8 100644
> --- a/include/libcamera/span.h
> +++ b/include/libcamera/span.h
> @@ -31,9 +31,6 @@ template<typename U, std::size_t N>
>  struct is_array<std::array<U, N>> : public std::true_type {
>  };
>  
> -template<typename T>
> -inline constexpr bool is_array_v = is_array<T>::value;
> -
>  template<typename U>
>  struct is_span : public std::false_type {
>  };
> @@ -42,9 +39,6 @@ template<typename U, std::size_t Extent>
>  struct is_span<Span<U, Extent>> : public std::true_type {
>  };
>  
> -template<typename T>
> -inline constexpr bool is_span_v = is_span<T>::value;
> -
>  } /* namespace details */
>  
>  namespace utils {
> @@ -161,8 +155,8 @@ public:
>  
>  	template<class Container>
>  	explicit constexpr Span(Container &cont,
> -				std::enable_if_t<!details::is_span_v<Container> &&
> -						 !details::is_array_v<Container> &&
> +				std::enable_if_t<!details::is_span<Container>::value &&
> +						 !details::is_array<Container>::value &&
>  						 !std::is_array_v<Container> &&
>  						 std::is_convertible_v<std::remove_pointer_t<decltype(utils::data(cont))> (*)[],
>  								       element_type (*)[]>,
> @@ -173,8 +167,8 @@ public:
>  
>  	template<class Container>
>  	explicit constexpr Span(const Container &cont,
> -				std::enable_if_t<!details::is_span_v<Container> &&
> -						 !details::is_array_v<Container> &&
> +				std::enable_if_t<!details::is_span<Container>::value &&
> +						 !details::is_array<Container>::value &&
>  						 !std::is_array_v<Container> &&
>  						 std::is_convertible_v<std::remove_pointer_t<decltype(utils::data(cont))> (*)[],
>  								       element_type (*)[]>,
> @@ -323,8 +317,8 @@ public:
>  
>  	template<class Container>
>  	constexpr Span(Container &cont,
> -		       std::enable_if_t<!details::is_span_v<Container> &&
> -					!details::is_array_v<Container> &&
> +		       std::enable_if_t<!details::is_span<Container>::value &&
> +					!details::is_array<Container>::value &&
>  					!std::is_array_v<Container> &&
>  					std::is_convertible_v<std::remove_pointer_t<decltype(utils::data(cont))> (*)[],
>  							      element_type (*)[]>,
> @@ -335,8 +329,8 @@ public:
>  
>  	template<class Container>
>  	constexpr Span(const Container &cont,
> -		       std::enable_if_t<!details::is_span_v<Container> &&
> -					!details::is_array_v<Container> &&
> +		       std::enable_if_t<!details::is_span<Container>::value &&
> +					!details::is_array<Container>::value &&
>  					!std::is_array_v<Container> &&
>  					std::is_convertible_v<std::remove_pointer_t<decltype(utils::data(cont))> (*)[],
>  							      element_type (*)[]>,
Jean-Michel Hautbois Jan. 31, 2021, 2:41 p.m. UTC | #2
Hi Laurent,

On 26/01/2021 22:22, Laurent Pinchart wrote:
> Hi Jean-Michel,
> 
> Thank you for the patch.
> 
> On Tue, Jan 26, 2021 at 02:04:14PM +0100, Jean-Michel Hautbois wrote:
>> This reverts commit 8e42c2feb7ff7c350ffbbf97dd963dfd54e21faa.
> 
> Missing Signed-off-by. Same for the next patch. Could you provide them
> in an e-mail reply ?

Sure :-)
Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>

>> ---
>>  include/libcamera/controls.h | 12 ++++++------
>>  include/libcamera/span.h     | 22 ++++++++--------------
>>  2 files changed, 14 insertions(+), 20 deletions(-)
>>
>> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
>> index 3634dc43..dc549a92 100644
>> --- a/include/libcamera/controls.h
>> +++ b/include/libcamera/controls.h
>> @@ -96,7 +96,7 @@ public:
>>  	ControlValue();
>>  
>>  #ifndef __DOXYGEN__
>> -	template<typename T, typename std::enable_if_t<!details::is_span_v<T> &&
>> +	template<typename T, typename std::enable_if_t<!details::is_span<T>::value &&
>>  						       details::control_type<T>::value &&
>>  						       !std::is_same_v<std::string, std::remove_cv_t<T>>,
>>  						       std::nullptr_t> = nullptr>
>> @@ -107,7 +107,7 @@ public:
>>  		    &value, 1, sizeof(T));
>>  	}
>>  
>> -	template<typename T, typename std::enable_if_t<details::is_span_v<T> ||
>> +	template<typename T, typename std::enable_if_t<details::is_span<T>::value ||
>>  						       std::is_same_v<std::string, std::remove_cv_t<T>>,
>>  						       std::nullptr_t> = nullptr>
>>  #else
>> @@ -141,7 +141,7 @@ public:
>>  	}
>>  
>>  #ifndef __DOXYGEN__
>> -	template<typename T, typename std::enable_if_t<!details::is_span_v<T> &&
>> +	template<typename T, typename std::enable_if_t<!details::is_span<T>::value &&
>>  						       !std::is_same_v<std::string, std::remove_cv_t<T>>,
>>  						       std::nullptr_t> = nullptr>
>>  	T get() const
>> @@ -152,7 +152,7 @@ public:
>>  		return *reinterpret_cast<const T *>(data().data());
>>  	}
>>  
>> -	template<typename T, typename std::enable_if_t<details::is_span_v<T> ||
>> +	template<typename T, typename std::enable_if_t<details::is_span<T>::value ||
>>  						       std::is_same_v<std::string, std::remove_cv_t<T>>,
>>  						       std::nullptr_t> = nullptr>
>>  #else
>> @@ -169,7 +169,7 @@ public:
>>  	}
>>  
>>  #ifndef __DOXYGEN__
>> -	template<typename T, typename std::enable_if_t<!details::is_span_v<T> &&
>> +	template<typename T, typename std::enable_if_t<!details::is_span<T>::value &&
>>  						       !std::is_same_v<std::string, std::remove_cv_t<T>>,
>>  						       std::nullptr_t> = nullptr>
>>  	void set(const T &value)
>> @@ -178,7 +178,7 @@ public:
>>  		    reinterpret_cast<const void *>(&value), 1, sizeof(T));
>>  	}
>>  
>> -	template<typename T, typename std::enable_if_t<details::is_span_v<T> ||
>> +	template<typename T, typename std::enable_if_t<details::is_span<T>::value ||
>>  						       std::is_same_v<std::string, std::remove_cv_t<T>>,
>>  						       std::nullptr_t> = nullptr>
>>  #else
>> diff --git a/include/libcamera/span.h b/include/libcamera/span.h
>> index e7ffef12..d720adb8 100644
>> --- a/include/libcamera/span.h
>> +++ b/include/libcamera/span.h
>> @@ -31,9 +31,6 @@ template<typename U, std::size_t N>
>>  struct is_array<std::array<U, N>> : public std::true_type {
>>  };
>>  
>> -template<typename T>
>> -inline constexpr bool is_array_v = is_array<T>::value;
>> -
>>  template<typename U>
>>  struct is_span : public std::false_type {
>>  };
>> @@ -42,9 +39,6 @@ template<typename U, std::size_t Extent>
>>  struct is_span<Span<U, Extent>> : public std::true_type {
>>  };
>>  
>> -template<typename T>
>> -inline constexpr bool is_span_v = is_span<T>::value;
>> -
>>  } /* namespace details */
>>  
>>  namespace utils {
>> @@ -161,8 +155,8 @@ public:
>>  
>>  	template<class Container>
>>  	explicit constexpr Span(Container &cont,
>> -				std::enable_if_t<!details::is_span_v<Container> &&
>> -						 !details::is_array_v<Container> &&
>> +				std::enable_if_t<!details::is_span<Container>::value &&
>> +						 !details::is_array<Container>::value &&
>>  						 !std::is_array_v<Container> &&
>>  						 std::is_convertible_v<std::remove_pointer_t<decltype(utils::data(cont))> (*)[],
>>  								       element_type (*)[]>,
>> @@ -173,8 +167,8 @@ public:
>>  
>>  	template<class Container>
>>  	explicit constexpr Span(const Container &cont,
>> -				std::enable_if_t<!details::is_span_v<Container> &&
>> -						 !details::is_array_v<Container> &&
>> +				std::enable_if_t<!details::is_span<Container>::value &&
>> +						 !details::is_array<Container>::value &&
>>  						 !std::is_array_v<Container> &&
>>  						 std::is_convertible_v<std::remove_pointer_t<decltype(utils::data(cont))> (*)[],
>>  								       element_type (*)[]>,
>> @@ -323,8 +317,8 @@ public:
>>  
>>  	template<class Container>
>>  	constexpr Span(Container &cont,
>> -		       std::enable_if_t<!details::is_span_v<Container> &&
>> -					!details::is_array_v<Container> &&
>> +		       std::enable_if_t<!details::is_span<Container>::value &&
>> +					!details::is_array<Container>::value &&
>>  					!std::is_array_v<Container> &&
>>  					std::is_convertible_v<std::remove_pointer_t<decltype(utils::data(cont))> (*)[],
>>  							      element_type (*)[]>,
>> @@ -335,8 +329,8 @@ public:
>>  
>>  	template<class Container>
>>  	constexpr Span(const Container &cont,
>> -		       std::enable_if_t<!details::is_span_v<Container> &&
>> -					!details::is_array_v<Container> &&
>> +		       std::enable_if_t<!details::is_span<Container>::value &&
>> +					!details::is_array<Container>::value &&
>>  					!std::is_array_v<Container> &&
>>  					std::is_convertible_v<std::remove_pointer_t<decltype(utils::data(cont))> (*)[],
>>  							      element_type (*)[]>,
>

Patch
diff mbox series

diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
index 3634dc43..dc549a92 100644
--- a/include/libcamera/controls.h
+++ b/include/libcamera/controls.h
@@ -96,7 +96,7 @@  public:
 	ControlValue();
 
 #ifndef __DOXYGEN__
-	template<typename T, typename std::enable_if_t<!details::is_span_v<T> &&
+	template<typename T, typename std::enable_if_t<!details::is_span<T>::value &&
 						       details::control_type<T>::value &&
 						       !std::is_same_v<std::string, std::remove_cv_t<T>>,
 						       std::nullptr_t> = nullptr>
@@ -107,7 +107,7 @@  public:
 		    &value, 1, sizeof(T));
 	}
 
-	template<typename T, typename std::enable_if_t<details::is_span_v<T> ||
+	template<typename T, typename std::enable_if_t<details::is_span<T>::value ||
 						       std::is_same_v<std::string, std::remove_cv_t<T>>,
 						       std::nullptr_t> = nullptr>
 #else
@@ -141,7 +141,7 @@  public:
 	}
 
 #ifndef __DOXYGEN__
-	template<typename T, typename std::enable_if_t<!details::is_span_v<T> &&
+	template<typename T, typename std::enable_if_t<!details::is_span<T>::value &&
 						       !std::is_same_v<std::string, std::remove_cv_t<T>>,
 						       std::nullptr_t> = nullptr>
 	T get() const
@@ -152,7 +152,7 @@  public:
 		return *reinterpret_cast<const T *>(data().data());
 	}
 
-	template<typename T, typename std::enable_if_t<details::is_span_v<T> ||
+	template<typename T, typename std::enable_if_t<details::is_span<T>::value ||
 						       std::is_same_v<std::string, std::remove_cv_t<T>>,
 						       std::nullptr_t> = nullptr>
 #else
@@ -169,7 +169,7 @@  public:
 	}
 
 #ifndef __DOXYGEN__
-	template<typename T, typename std::enable_if_t<!details::is_span_v<T> &&
+	template<typename T, typename std::enable_if_t<!details::is_span<T>::value &&
 						       !std::is_same_v<std::string, std::remove_cv_t<T>>,
 						       std::nullptr_t> = nullptr>
 	void set(const T &value)
@@ -178,7 +178,7 @@  public:
 		    reinterpret_cast<const void *>(&value), 1, sizeof(T));
 	}
 
-	template<typename T, typename std::enable_if_t<details::is_span_v<T> ||
+	template<typename T, typename std::enable_if_t<details::is_span<T>::value ||
 						       std::is_same_v<std::string, std::remove_cv_t<T>>,
 						       std::nullptr_t> = nullptr>
 #else
diff --git a/include/libcamera/span.h b/include/libcamera/span.h
index e7ffef12..d720adb8 100644
--- a/include/libcamera/span.h
+++ b/include/libcamera/span.h
@@ -31,9 +31,6 @@  template<typename U, std::size_t N>
 struct is_array<std::array<U, N>> : public std::true_type {
 };
 
-template<typename T>
-inline constexpr bool is_array_v = is_array<T>::value;
-
 template<typename U>
 struct is_span : public std::false_type {
 };
@@ -42,9 +39,6 @@  template<typename U, std::size_t Extent>
 struct is_span<Span<U, Extent>> : public std::true_type {
 };
 
-template<typename T>
-inline constexpr bool is_span_v = is_span<T>::value;
-
 } /* namespace details */
 
 namespace utils {
@@ -161,8 +155,8 @@  public:
 
 	template<class Container>
 	explicit constexpr Span(Container &cont,
-				std::enable_if_t<!details::is_span_v<Container> &&
-						 !details::is_array_v<Container> &&
+				std::enable_if_t<!details::is_span<Container>::value &&
+						 !details::is_array<Container>::value &&
 						 !std::is_array_v<Container> &&
 						 std::is_convertible_v<std::remove_pointer_t<decltype(utils::data(cont))> (*)[],
 								       element_type (*)[]>,
@@ -173,8 +167,8 @@  public:
 
 	template<class Container>
 	explicit constexpr Span(const Container &cont,
-				std::enable_if_t<!details::is_span_v<Container> &&
-						 !details::is_array_v<Container> &&
+				std::enable_if_t<!details::is_span<Container>::value &&
+						 !details::is_array<Container>::value &&
 						 !std::is_array_v<Container> &&
 						 std::is_convertible_v<std::remove_pointer_t<decltype(utils::data(cont))> (*)[],
 								       element_type (*)[]>,
@@ -323,8 +317,8 @@  public:
 
 	template<class Container>
 	constexpr Span(Container &cont,
-		       std::enable_if_t<!details::is_span_v<Container> &&
-					!details::is_array_v<Container> &&
+		       std::enable_if_t<!details::is_span<Container>::value &&
+					!details::is_array<Container>::value &&
 					!std::is_array_v<Container> &&
 					std::is_convertible_v<std::remove_pointer_t<decltype(utils::data(cont))> (*)[],
 							      element_type (*)[]>,
@@ -335,8 +329,8 @@  public:
 
 	template<class Container>
 	constexpr Span(const Container &cont,
-		       std::enable_if_t<!details::is_span_v<Container> &&
-					!details::is_array_v<Container> &&
+		       std::enable_if_t<!details::is_span<Container>::value &&
+					!details::is_array<Container>::value &&
 					!std::is_array_v<Container> &&
 					std::is_convertible_v<std::remove_pointer_t<decltype(utils::data(cont))> (*)[],
 							      element_type (*)[]>,