[rtems commit] thread.hpp: Fix redefinition of default argument

Sebastian Huber sebh at rtems.org
Sat Mar 19 09:23:57 UTC 2022


Module:    rtems
Branch:    master
Commit:    7fe3c623290a3f17d37241748410c8484a326483
Changeset: http://git.rtems.org/rtems/commit/?id=7fe3c623290a3f17d37241748410c8484a326483

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Mar 18 16:13:04 2022 +0100

thread.hpp: Fix redefinition of default argument

A default argument shall be defined only once.

Close #4632.

---

 cpukit/include/rtems/thread.hpp | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/cpukit/include/rtems/thread.hpp b/cpukit/include/rtems/thread.hpp
index cdef690..56e301c 100644
--- a/cpukit/include/rtems/thread.hpp
+++ b/cpukit/include/rtems/thread.hpp
@@ -220,6 +220,12 @@ namespace rtems
       /* affinity, cpu set size is? */
     };
 
+    template <class T>
+    inline typename std::decay<T>::type
+    decay_copy(T&& t) {
+      return std::forward<T>(t);
+    }
+
     /**
      * @brief Create a thread with thread attributes.
      *
@@ -310,7 +316,14 @@ namespace rtems
        */
       template <typename A, typename F, typename ...Args,
                 class = enable_if_attributes<A>>
-      explicit thread(A&& attr, F&& func, Args&&... args);
+      explicit thread(A&& attr, F&& func, Args&&... args)
+        : id_(0) {
+        start_thread(
+          make_state(attr,
+                     make_invoker(decay_copy(std::forward<F>(func)),
+                                  decay_copy(std::forward<Args>(args))...))
+        );
+      }
 
       /**
        * Move the thread id to this instance.
@@ -428,12 +441,6 @@ namespace rtems
       void start_thread(state_ptr s);
     };
 
-    template <class T>
-    inline typename std::decay<T>::type
-    decay_copy(T&& t) {
-      return std::forward<T>(t);
-    }
-
     template<typename F, typename... Args>
     thread::thread(F&& func, Args&&... args)
       : id_(0)  {
@@ -445,17 +452,6 @@ namespace rtems
       );
     }
 
-    template<typename A, typename F, typename... Args,
-             class = thread::enable_if_attributes<A>>
-    thread::thread(A&& attr, F&& func, Args&&... args)
-      : id_(0) {
-      start_thread(
-        make_state(attr,
-                   make_invoker(decay_copy(std::forward<F>(func)),
-                                decay_copy(std::forward<Args>(args))...))
-      );
-    }
-
     inline std::thread::id thread::get_id() const noexcept {
       return std::thread::id(id_.id_);
     }



More information about the vc mailing list