From 57c755c415d1c609df90519fc40e2682b62e1f63 Mon Sep 17 00:00:00 2001 From: EntireTwix Date: Wed, 21 Apr 2021 19:11:56 -0700 Subject: [PATCH] :bug: fixed last commit --- include/bank.hpp | 11 ++++++----- include/log.hpp | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/bank.hpp b/include/bank.hpp index 95584ae..3c4e4f9 100644 --- a/include/bank.hpp +++ b/include/bank.hpp @@ -109,21 +109,22 @@ public: if (state) { //if user lacks a log, one is created, this is to reduce usage - Transaction temp(a_name, b_name, amount, false); + Transaction temp(a_name, b_name, amount); + Transaction temp2(a_name, b_name, amount); + if (!logs.contains(a_name)) { logs.try_emplace(a_name); } logs.modify_if(a_name, [&temp](Log &l) { - l.AddTrans(temp); + l.AddTrans(std::move(temp)); }); if (!logs.contains(b_name)) { logs.try_emplace(b_name); } - temp.recieving = true; - logs.modify_if(b_name, [&temp](Log &l) { - l.AddTrans(temp); + logs.modify_if(b_name, [&temp2](Log &l) { + l.AddTrans(std::move(temp2)); }); } diff --git a/include/log.hpp b/include/log.hpp index f76f4d3..9c83e53 100644 --- a/include/log.hpp +++ b/include/log.hpp @@ -6,7 +6,7 @@ struct Log { std::array data; - void AddTrans(const Transaction &v) + void AddTrans(Transaction &&v) { std::rotate(data.begin(), data.begin() + 1, data.end()); data[99] = std::move(v);