Commit 45c0f87af2466d4e510678f256bf50d20a9068ec
1 parent
d0e55e33
Bugfix
Showing
3 changed files
with
8 additions
and
5 deletions
examples11/04-vectortmpl/vector.h
@@ -38,7 +38,8 @@ private: | @@ -38,7 +38,8 @@ private: | ||
38 | unsigned i; | 38 | unsigned i; |
39 | try { | 39 | try { |
40 | for (i = 0; i < size; i++) | 40 | for (i = 0; i < size; i++) |
41 | - new (newdata + i) C(std::move(data[i])); | 41 | +// new (newdata + i) C(std::move(data[i])); |
42 | + new (newdata + i) C(data[i]); | ||
42 | } catch (...) { | 43 | } catch (...) { |
43 | destroy_array(newdata, i); | 44 | destroy_array(newdata, i); |
44 | throw; | 45 | throw; |
examples11/05-foldexpr/vector.h
@@ -38,7 +38,8 @@ private: | @@ -38,7 +38,8 @@ private: | ||
38 | unsigned i; | 38 | unsigned i; |
39 | try { | 39 | try { |
40 | for (i = 0; i < size; i++) | 40 | for (i = 0; i < size; i++) |
41 | - new (newdata + i) C(std::move(data[i])); | 41 | + new (newdata + i) C(data[i]); |
42 | +// new (newdata + i) C(std::move(data[i])); | ||
42 | } catch (...) { | 43 | } catch (...) { |
43 | destroy_array(newdata, i); | 44 | destroy_array(newdata, i); |
44 | throw; | 45 | throw; |
examples11/06-template_metaprogramming/vector.h
@@ -36,7 +36,8 @@ private: | @@ -36,7 +36,8 @@ private: | ||
36 | unsigned i; | 36 | unsigned i; |
37 | try { | 37 | try { |
38 | for (i = 0; i < size; i++) | 38 | for (i = 0; i < size; i++) |
39 | - new (newdata + i) C(std::move(data[i])); | 39 | + new (newdata + i) C(data[i]); |
40 | +// new (newdata + i) C(std::move(data[i])); | ||
40 | } catch (...) { | 41 | } catch (...) { |
41 | destroy_array(newdata, i); | 42 | destroy_array(newdata, i); |
42 | throw; | 43 | throw; |
@@ -157,12 +158,12 @@ public: | @@ -157,12 +158,12 @@ public: | ||
157 | } | 158 | } |
158 | 159 | ||
159 | template <class T> std::tuple<C &> push_back(T &&s) { | 160 | template <class T> std::tuple<C &> push_back(T &&s) { |
160 | - C &r = emplace_back(std::forward<C>(s)); | 161 | + C &r = emplace_back(std::forward<T>(s)); |
161 | return std::tuple<C &>(r); | 162 | return std::tuple<C &>(r); |
162 | } | 163 | } |
163 | 164 | ||
164 | template <class T, class... Args> auto push_back(T &&a, Args &&... args) { | 165 | template <class T, class... Args> auto push_back(T &&a, Args &&... args) { |
165 | - auto op1 = push_back(std::forward<C>(a)); | 166 | + auto op1 = push_back(std::forward<T>(a)); |
166 | auto op2 = push_back(args...); | 167 | auto op2 = push_back(args...); |
167 | return std::tuple_cat(op1, op2); | 168 | return std::tuple_cat(op1, op2); |
168 | } | 169 | } |