Эх сурвалжийг харах

fix(c++): template forwarding should use &&

greatbridf 2 жил өмнө
parent
commit
93685f6053

+ 4 - 4
include/types/allocator.hpp

@@ -45,13 +45,13 @@ public:
 };
 
 template <typename T, typename... Args>
-T* kernel_allocator_new(Args... args)
+T* kernel_allocator_new(Args&&... args)
 {
     return allocator_traits<kernel_allocator<T>>::allocate_and_construct(args...);
 }
 
 template <typename T, typename... Args>
-T* kernel_ident_allocator_new(Args... args)
+T* kernel_ident_allocator_new(Args&&... args)
 {
     return allocator_traits<kernel_ident_allocator<T>>::allocate_and_construct(args...);
 }
@@ -69,14 +69,14 @@ public:
     }
 
     template <typename... Args>
-    static value_type* construct(value_type* ptr, Args... args)
+    static value_type* construct(value_type* ptr, Args&&... args)
     {
         new (ptr) value_type(args...);
         return ptr;
     }
 
     template <typename... Args>
-    static value_type* allocate_and_construct(Args... args)
+    static value_type* allocate_and_construct(Args&&... args)
     {
         auto* ptr = allocate(1);
         construct(ptr, args...);

+ 3 - 3
include/types/list.hpp

@@ -237,7 +237,7 @@ public:
     {
         node_base_type* new_node = allocator_traits<allocator_type>::allocate_and_construct(v);
         iterator_type ret(new_node);
-        iter._node().prev->connect(new_node);
+        iter._node()->prev->connect(new_node);
         new_node->connect(iter._node());
 
         ++_size();
@@ -255,7 +255,7 @@ public:
     }
 
     template <typename... Args>
-    reference_type emplace_back(Args... args)
+    iterator_type emplace_back(Args&&... args)
     {
         return insert(end(), value_type(args...));
     }
@@ -271,7 +271,7 @@ public:
     }
 
     template <typename... Args>
-    reference_type emplace_front(Args... args)
+    iterator_type emplace_front(Args&&... args)
     {
         return insert(begin(), value_type(args...));
     }

+ 1 - 1
include/types/vector.hpp

@@ -231,7 +231,7 @@ public:
     }
 
     template <typename... Args>
-    iterator_type emplace_back(Args... args)
+    iterator_type emplace_back(Args&&... args)
     {
         push_back(value_type(args...));
         return back();