Gabe Black has submitted this change and it was merged. ( https://gem5-review.googlesource.com/c/public/gem5/+/13193 )

Change subject: systemc: Use c++11 partial functions instead of boosts.
......................................................................

systemc: Use c++11 partial functions instead of boosts.

This creates a depenendency on c++11 which the headers otherwise avoid,
but gem5 itself already has a c++11 dependency and not a boost
dependency, and outside of having a local copy of boost (which
Accellera does) there isn't a good way to put the placeholder values
_1, _2, etc., into the custom sc_unnammed namespace.

Change-Id: I52ca4c1bc52bef6ff2c62e9f3c32af46f95244dc
Reviewed-on: https://gem5-review.googlesource.com/c/13193
Reviewed-by: Gabe Black <[email protected]>
Maintainer: Gabe Black <[email protected]>
---
M src/systemc/core/sc_spawn.cc
M src/systemc/ext/core/sc_spawn.hh
2 files changed, 27 insertions(+), 29 deletions(-)

Approvals:
  Gabe Black: Looks good to me, approved; Looks good to me, approved



diff --git a/src/systemc/core/sc_spawn.cc b/src/systemc/core/sc_spawn.cc
index 4618ea8..ed7f2f2 100644
--- a/src/systemc/core/sc_spawn.cc
+++ b/src/systemc/core/sc_spawn.cc
@@ -224,18 +224,3 @@
 }

 } // namespace sc_core
-
-namespace sc_unnamed
-{
-
-ImplementationDefined _1;
-ImplementationDefined _2;
-ImplementationDefined _3;
-ImplementationDefined _4;
-ImplementationDefined _5;
-ImplementationDefined _6;
-ImplementationDefined _7;
-ImplementationDefined _8;
-ImplementationDefined _9;
-
-} // namespace sc_unnamed
diff --git a/src/systemc/ext/core/sc_spawn.hh b/src/systemc/ext/core/sc_spawn.hh
index 50378e2..a37e482 100644
--- a/src/systemc/ext/core/sc_spawn.hh
+++ b/src/systemc/ext/core/sc_spawn.hh
@@ -30,6 +30,7 @@
 #ifndef __SYSTEMC_EXT_CORE_SC_SPAWN_HH__
 #define __SYSTEMC_EXT_CORE_SC_SPAWN_HH__

+#include <functional>
 #include <vector>

 #include "sc_join.hh"
@@ -173,10 +174,6 @@
     return sc_process_handle() = p;
 }

-#define sc_bind boost::bind
-#define sc_ref(r) boost::ref(r)
-#define sc_cref(r) boost::cref(r)
-
 #define SC_FORK \
 { \
     ::sc_core::sc_process_handle forkees[] = {
@@ -198,22 +195,38 @@
     join.wait_clocked(); \
 }

+// This avoids boost introduces a dependency on c++11. If that's a problem,
+// we could imitate Accellera and pick which one to use on the fly.
+
+template <typename F, typename... Args>
+auto sc_bind(F &&f, Args && ...args) ->
+    decltype(std::bind(std::forward<F>(f), std::forward<Args>(args)...))
+{
+    return std::bind(std::forward<F>(f), std::forward<Args>(args)...);
+}
+
+template <typename T>
+auto sc_ref(T &&v) -> decltype(std::ref(std::forward<T>(v)))
+{
+    return std::ref(std::forward<T>(v));
+}
+
+template <typename T>
+auto sc_cref(T &&v) -> decltype(std::cref(std::forward<T>(v)))
+{
+    return std::cref(std::forward<T>(v));
+}

 } // namespace sc_core

+using sc_core::sc_bind;
+using sc_core::sc_ref;
+using sc_core::sc_cref;
+
 namespace sc_unnamed
 {

-typedef int ImplementationDefined;
-extern ImplementationDefined _1;
-extern ImplementationDefined _2;
-extern ImplementationDefined _3;
-extern ImplementationDefined _4;
-extern ImplementationDefined _5;
-extern ImplementationDefined _6;
-extern ImplementationDefined _7;
-extern ImplementationDefined _8;
-extern ImplementationDefined _9;
+using namespace std::placeholders;

 } // namespace sc_unnamed


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

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I52ca4c1bc52bef6ff2c62e9f3c32af46f95244dc
Gerrit-Change-Number: 13193
Gerrit-PatchSet: 5
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Matthias Jung <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to