From 485f513a29058e3fecb05e41593d13204bb7c9e5 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 9 Aug 2016 16:57:36 -0400 Subject: [PATCH] Manually create move the constructor/assignment for Instruction. This is because some old visual studio versions (e.g., 2013) do not support automatically generating move constructors/assignments. --- source/opt/instruction.cpp | 16 ++++++++++++++++ source/opt/instruction.h | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/source/opt/instruction.cpp b/source/opt/instruction.cpp index a643d72..65fb529 100644 --- a/source/opt/instruction.cpp +++ b/source/opt/instruction.cpp @@ -50,6 +50,22 @@ Instruction::Instruction(const spv_parsed_instruction_t& inst, } } +Instruction::Instruction(Instruction&& that) + : opcode_(that.opcode_), + type_id_(that.type_id_), + result_id_(that.result_id_), + operands_(std::move(that.operands_)), + dbg_line_insts_(std::move(that.dbg_line_insts_)) {} + +Instruction& Instruction::operator=(Instruction&& that) { + opcode_ = that.opcode_; + type_id_ = that.type_id_; + result_id_ = that.result_id_; + operands_ = std::move(that.operands_); + dbg_line_insts_ = std::move(that.dbg_line_insts_); + return *this; +} + uint32_t Instruction::GetSingleWordOperand(uint32_t index) const { const auto& words = GetOperand(index).words; assert(words.size() == 1 && "expected the operand only taking one word"); diff --git a/source/opt/instruction.h b/source/opt/instruction.h index 18447ca..6c53f08 100644 --- a/source/opt/instruction.h +++ b/source/opt/instruction.h @@ -88,8 +88,8 @@ class Instruction { Instruction(const Instruction&) = default; Instruction& operator=(const Instruction&) = default; - Instruction(Instruction&&) = default; - Instruction& operator=(Instruction&&) = default; + Instruction(Instruction&&); + Instruction& operator=(Instruction&&); SpvOp opcode() const { return opcode_; } // Sets the opcode of this instruction to a specific opcode. Note this may -- 2.7.4