From dbd8533e392ed778f7ec5aa94e704a46d3b7130c Mon Sep 17 00:00:00 2001 From: Eric Schweitz Date: Fri, 5 Apr 2019 10:08:19 -0700 Subject: [PATCH] [flang] use std::forward, avoid std::move usage bugs Original-commit: flang-compiler/f18@0d66bc243919a46a518067c59881e82e32552f62 Reviewed-on: https://github.com/flang-compiler/f18/pull/385 Tree-same-pre-rewrite: false --- flang/lib/FIR/mixin.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/flang/lib/FIR/mixin.h b/flang/lib/FIR/mixin.h index 0304b9e..778dd8b 100644 --- a/flang/lib/FIR/mixin.h +++ b/flang/lib/FIR/mixin.h @@ -30,7 +30,7 @@ namespace Fortran::FIR { // implementation of a (moveable) sum type (variant) template struct SumTypeMixin { - template SumTypeMixin(A &&x) : u{std::move(x)} {} + template SumTypeMixin(A &&x) : u{std::forward(x)} {} using SumTypeTrait = std::true_type; SumTypeMixin(SumTypeMixin &&) = default; SumTypeMixin &operator=(SumTypeMixin &&) = default; @@ -42,8 +42,7 @@ template struct SumTypeMixin { // implementation of a copyable sum type template struct SumTypeCopyMixin { - template SumTypeCopyMixin(A &&x) : u{std::move(x)} {} - template SumTypeCopyMixin(const A &x) : u{x} {} + template SumTypeCopyMixin(A &&x) : u{std::forward(x)} {} using CopyableSumTypeTrait = std::true_type; SumTypeCopyMixin(SumTypeCopyMixin &&) = default; SumTypeCopyMixin &operator=(SumTypeCopyMixin &&) = default; @@ -61,7 +60,7 @@ template struct SumTypeCopyMixin { // implementation of a (moveable) product type (tuple) template struct ProductTypeMixin { - template ProductTypeMixin(A &&x) : t{std::move(x)} {} + ProductTypeMixin(Ts... x) : t{std::forward(x)...} {} using ProductTypeTrait = std::true_type; ProductTypeMixin(ProductTypeMixin &&) = default; ProductTypeMixin &operator=(ProductTypeMixin &&) = default; @@ -73,7 +72,7 @@ template struct ProductTypeMixin { // implementation of a (moveable) maybe type template struct MaybeMixin { - MaybeMixin(T &&x) : o{std::move(x)} {} + MaybeMixin(T &&x) : o{std::forward(x)} {} using MaybeTrait = std::true_type; MaybeMixin(MaybeMixin &&) = default; MaybeMixin &operator=(MaybeMixin &&) = default; -- 2.7.4