From eb0a0641fe2a576a743d7ec36a4b2bfec1ec37d7 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 17 Dec 2020 01:00:07 +0000 Subject: Fix case where prefix view could be of a moved string --- slicer/tool/icemetadata.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/slicer/tool/icemetadata.cpp b/slicer/tool/icemetadata.cpp index 64806d6..0d8d7bc 100644 --- a/slicer/tool/icemetadata.cpp +++ b/slicer/tool/icemetadata.cpp @@ -5,9 +5,9 @@ namespace Slicer { IceMetaData::IceMetaData(Slice::StringList && a) { arr.reserve(a.size()); - std::transform(a.begin(), a.end(), std::back_inserter(arr), [](auto a) { - auto prefix = std::string_view(a).substr(0, a.rfind(':')); - return std::make_pair(std::move(a), prefix); + std::for_each(a.begin(), a.end(), [this](auto && a) { + auto & md = arr.emplace_back(a, std::string_view {}); + md.second = std::string_view(md.first).substr(0, md.first.rfind(':')); }); _begin = arr.begin(); _end = arr.end(); -- cgit v1.2.3