From f94674e9a8bc3e19d45f071818e787c32153585f Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 15 Apr 2022 17:28:06 +0100 Subject: Fix shadowing in metadata and simplify --- slicer/slicer/metadata.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/slicer/slicer/metadata.h b/slicer/slicer/metadata.h index 8aa65c9..bf2fcef 100644 --- a/slicer/slicer/metadata.h +++ b/slicer/slicer/metadata.h @@ -110,14 +110,11 @@ namespace Slicer { using Arr = ContainerBase; constexpr inline explicit MetaDataImpl(const std::array & a) : arr {[&a]() { - Arr arr; - auto out = arr.begin(); - for (const auto & md : a) { - out->first = md; - out->second = out->first.substr(0, out->first.rfind(':')); - out++; - } - return arr; + Arr rtn; + std::transform(a.begin(), a.end(), rtn.begin(), [](const auto & md) -> typename Arr::value_type { + return {md, md.substr(0, md.rfind(':'))}; + }); + return rtn; }()} { _begin = arr.begin(); -- cgit v1.2.3