[libcamera-devel] libcamera: utils: Don't use C++17 nested namespaces

Message ID 20190118130823.22541-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit 576c9454cfc9529852a7b0da3e5bfb465fb4baa5
Headers show
Series
  • [libcamera-devel] libcamera: utils: Don't use C++17 nested namespaces
Related show

Commit Message

Laurent Pinchart Jan. 18, 2019, 1:08 p.m. UTC
Nesting namespace names in a single namespace declaration is a C++17
feature. As libcamera depends on C++11 only, nest two separate namespace
declarations instead.

Reported-by: Shik Chen <shik@google.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/include/utils.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Niklas Söderlund Jan. 18, 2019, 3:38 p.m. UTC | #1
Hi Laurent,

Thanks for your work.

On 2019-01-18 15:08:23 +0200, Laurent Pinchart wrote:
> Nesting namespace names in a single namespace declaration is a C++17
> feature. As libcamera depends on C++11 only, nest two separate namespace
> declarations instead.
> 
> Reported-by: Shik Chen <shik@google.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  src/libcamera/include/utils.h | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h
> index a2e450b35372..73fa2e69b029 100644
> --- a/src/libcamera/include/utils.h
> +++ b/src/libcamera/include/utils.h
> @@ -11,7 +11,9 @@
>  
>  #define ARRAY_SIZE(a)	(sizeof(a) / sizeof(a[0]))
>  
> -namespace libcamera::utils {
> +namespace libcamera {
> +
> +namespace utils {
>  
>  /* C++11 doesn't provide std::make_unique */
>  template<typename T, typename... Args>
> @@ -20,6 +22,8 @@ std::unique_ptr<T> make_unique(Args&&... args)
>  	return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
>  }
>  
> -} /* namespace libcamera::utils */
> +} /* namespace utils */
> +
> +} /* namespace libcamera */
>  
>  #endif /* __LIBCAMERA_UTILS_H__ */
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h
index a2e450b35372..73fa2e69b029 100644
--- a/src/libcamera/include/utils.h
+++ b/src/libcamera/include/utils.h
@@ -11,7 +11,9 @@ 
 
 #define ARRAY_SIZE(a)	(sizeof(a) / sizeof(a[0]))
 
-namespace libcamera::utils {
+namespace libcamera {
+
+namespace utils {
 
 /* C++11 doesn't provide std::make_unique */
 template<typename T, typename... Args>
@@ -20,6 +22,8 @@  std::unique_ptr<T> make_unique(Args&&... args)
 	return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
 }
 
-} /* namespace libcamera::utils */
+} /* namespace utils */
+
+} /* namespace libcamera */
 
 #endif /* __LIBCAMERA_UTILS_H__ */