You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by sw...@apache.org on 2023/10/19 03:57:37 UTC

[logging-log4cxx] branch master updated: Prevent SonarCloud warning (#276)

This is an automated email from the ASF dual-hosted git repository.

swebb2066 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git


The following commit(s) were added to refs/heads/master by this push:
     new 624642a4 Prevent SonarCloud warning (#276)
624642a4 is described below

commit 624642a4e1c14d23cacca6df736ee4a7e83f878d
Author: Stephen Webb <st...@ieee.org>
AuthorDate: Thu Oct 19 14:57:32 2023 +1100

    Prevent SonarCloud warning (#276)
---
 src/main/include/log4cxx/helpers/widelife.h | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/main/include/log4cxx/helpers/widelife.h b/src/main/include/log4cxx/helpers/widelife.h
index aee30157..bafcf982 100644
--- a/src/main/include/log4cxx/helpers/widelife.h
+++ b/src/main/include/log4cxx/helpers/widelife.h
@@ -19,6 +19,9 @@
 #define _LOG4CXX_HELPERS_WIDELIFE_H
 
 #include <log4cxx/log4cxx.h>
+#if defined(__cpp_concepts) && __cpp_concepts >= 201500
+#include <concepts>
+#endif
 
 namespace log4cxx
 {
@@ -33,10 +36,17 @@ template <class T>
 class WideLife
 {
 public:
-	template <class... Args>
-	WideLife(Args&&... args)
+	WideLife()
+	{		
+		new(&storage) T();
+	}
+	template <class Arg0, class... Args>
+#if defined(__cpp_concepts) && __cpp_concepts >= 201500
+		requires (!std::same_as<WideLife, Arg0>)
+#endif
+	WideLife(Arg0&& arg0, Args&&... args)
 	{		
-		new(&storage) T(std::forward<Args>(args)...);
+		new(&storage) T(std::forward<Arg0>(arg0), std::forward<Args>(args)...);
 	}
 	
 	~WideLife()