[01/11] libcamera: yaml_parser: Drop std::enable_if_t guards for get() function
diff mbox series

Message ID 20240613013944.23344-2-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • ipa: libipa: Vector and Pwl improvements
Related show

Commit Message

Laurent Pinchart June 13, 2024, 1:39 a.m. UTC
The YamlObject::get() function template is implemented for a set of
basic types through template specializations. The function declaration
uses std::enable_if_t<> guards to signal incorrect usage at compilation
time. This however prevents the API to be extended with additional
specializations in other compilation units.

To prepare for new specializations of the function for the ipa::Vector
and ipa::Pwl classes types, implemented in their respective compilation
units, drop the std::enable_it_t<> guards. Incorrect usage will still be
reported as link errors.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 include/libcamera/internal/yaml_parser.h | 15 ---------------
 1 file changed, 15 deletions(-)

Comments

Paul Elder June 13, 2024, 7:23 a.m. UTC | #1
On Thu, Jun 13, 2024 at 04:39:34AM +0300, Laurent Pinchart wrote:
> The YamlObject::get() function template is implemented for a set of
> basic types through template specializations. The function declaration
> uses std::enable_if_t<> guards to signal incorrect usage at compilation
> time. This however prevents the API to be extended with additional
> specializations in other compilation units.
> 
> To prepare for new specializations of the function for the ipa::Vector
> and ipa::Pwl classes types, implemented in their respective compilation
> units, drop the std::enable_it_t<> guards. Incorrect usage will still be
> reported as link errors.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  include/libcamera/internal/yaml_parser.h | 15 ---------------
>  1 file changed, 15 deletions(-)
> 
> diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h
> index 3ac27e06f69d..81cc0e25ae0f 100644
> --- a/include/libcamera/internal/yaml_parser.h
> +++ b/include/libcamera/internal/yaml_parser.h
> @@ -161,22 +161,7 @@ public:
>  
>  	std::size_t size() const;
>  
> -#ifndef __DOXYGEN__
> -	template<typename T,
> -		 std::enable_if_t<
> -			 std::is_same_v<bool, T> ||
> -			 std::is_same_v<double, T> ||
> -			 std::is_same_v<int8_t, T> ||
> -			 std::is_same_v<uint8_t, T> ||
> -			 std::is_same_v<int16_t, T> ||
> -			 std::is_same_v<uint16_t, T> ||
> -			 std::is_same_v<int32_t, T> ||
> -			 std::is_same_v<uint32_t, T> ||
> -			 std::is_same_v<std::string, T> ||
> -			 std::is_same_v<Size, T>> * = nullptr>
> -#else
>  	template<typename T>
> -#endif
>  	std::optional<T> get() const;
>  
>  	template<typename T, typename U>
Kieran Bingham June 13, 2024, 11:07 a.m. UTC | #2
Quoting Laurent Pinchart (2024-06-13 02:39:34)
> The YamlObject::get() function template is implemented for a set of
> basic types through template specializations. The function declaration
> uses std::enable_if_t<> guards to signal incorrect usage at compilation
> time. This however prevents the API to be extended with additional
> specializations in other compilation units.
> 
> To prepare for new specializations of the function for the ipa::Vector
> and ipa::Pwl classes types, implemented in their respective compilation
> units, drop the std::enable_it_t<> guards. Incorrect usage will still be
> reported as link errors.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  include/libcamera/internal/yaml_parser.h | 15 ---------------
>  1 file changed, 15 deletions(-)
> 
> diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h
> index 3ac27e06f69d..81cc0e25ae0f 100644
> --- a/include/libcamera/internal/yaml_parser.h
> +++ b/include/libcamera/internal/yaml_parser.h
> @@ -161,22 +161,7 @@ public:
>  
>         std::size_t size() const;
>  
> -#ifndef __DOXYGEN__
> -       template<typename T,
> -                std::enable_if_t<
> -                        std::is_same_v<bool, T> ||
> -                        std::is_same_v<double, T> ||
> -                        std::is_same_v<int8_t, T> ||
> -                        std::is_same_v<uint8_t, T> ||
> -                        std::is_same_v<int16_t, T> ||
> -                        std::is_same_v<uint16_t, T> ||
> -                        std::is_same_v<int32_t, T> ||
> -                        std::is_same_v<uint32_t, T> ||
> -                        std::is_same_v<std::string, T> ||
> -                        std::is_same_v<Size, T>> * = nullptr>
> -#else
>         template<typename T>
> -#endif
>         std::optional<T> get() const;
>  
>         template<typename T, typename U>
> -- 
> Regards,
> 
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h
index 3ac27e06f69d..81cc0e25ae0f 100644
--- a/include/libcamera/internal/yaml_parser.h
+++ b/include/libcamera/internal/yaml_parser.h
@@ -161,22 +161,7 @@  public:
 
 	std::size_t size() const;
 
-#ifndef __DOXYGEN__
-	template<typename T,
-		 std::enable_if_t<
-			 std::is_same_v<bool, T> ||
-			 std::is_same_v<double, T> ||
-			 std::is_same_v<int8_t, T> ||
-			 std::is_same_v<uint8_t, T> ||
-			 std::is_same_v<int16_t, T> ||
-			 std::is_same_v<uint16_t, T> ||
-			 std::is_same_v<int32_t, T> ||
-			 std::is_same_v<uint32_t, T> ||
-			 std::is_same_v<std::string, T> ||
-			 std::is_same_v<Size, T>> * = nullptr>
-#else
 	template<typename T>
-#endif
 	std::optional<T> get() const;
 
 	template<typename T, typename U>