Giacomo Travaglini has submitted this change and it was merged. ( https://gem5-review.googlesource.com/5201 )

Change subject: base: Defining make_unique for C++11
......................................................................

base: Defining make_unique for C++11

std::make_unique is not available for C++11 compilers, and it has been
introduced only in C++14.  Since gem5 is not officially supporting the
latter at the moment, this patch allows to use it in gem5 if including
base/compiler.hh. If compiled under C++14, std::make_unique will be
used instead.

Change-Id: Ibf1897fad0a1eb1cb0c683cc25170feaa6841997
Signed-off-by: Giacomo Travaglini <[email protected]>
Reviewed-by: Andreas Sandberg <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/5201
Reviewed-by: Anthony Gutierrez <[email protected]>
Reviewed-by: Jason Lowe-Power <[email protected]>
Maintainer: Jason Lowe-Power <[email protected]>
---
M src/base/compiler.hh
1 file changed, 27 insertions(+), 1 deletion(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  Anthony Gutierrez: Looks good to me, approved



diff --git a/src/base/compiler.hh b/src/base/compiler.hh
index 9cad07d..2fdd323 100644
--- a/src/base/compiler.hh
+++ b/src/base/compiler.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 ARM Limited
+ * Copyright (c) 2012,2017 ARM Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
@@ -43,6 +43,8 @@
 #ifndef __BASE_COMPILER_HH__
 #define __BASE_COMPILER_HH__

+#include <memory>
+
 // http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html

 #if defined(__GNUC__) // clang or gcc
@@ -61,4 +63,28 @@
 #  define M5_CLASS_VAR_USED
 #endif

+// std::make_unique redefined for C++11 compilers
+namespace m5
+{
+
+#if __cplusplus == 201402L // C++14
+
+using std::make_unique;
+
+#else // C++11
+
+/** Defining custom version of make_unique: m5::make_unique<>() */
+template<typename T, typename... Args>
+std::unique_ptr<T>
+make_unique( Args&&... constructor_args )
+{
+    return std::unique_ptr<T>(
+               new T( std::forward<Args>(constructor_args)... )
+           );
+}
+
+#endif // __cplusplus == 201402L
+
+} //namespace m5
+
 #endif // __BASE_COMPILER_HH__

--
To view, visit https://gem5-review.googlesource.com/5201
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibf1897fad0a1eb1cb0c683cc25170feaa6841997
Gerrit-Change-Number: 5201
Gerrit-PatchSet: 2
Gerrit-Owner: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Anthony Gutierrez <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to