From 54024217a529ebd63f459a020e395401a881c8c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Can=20B=C3=B6l=C3=BCk?= Date: Fri, 28 Aug 2020 06:49:49 +0200 Subject: [PATCH] Fixing reference-to-reference issues. --- VTIL-Common/io/formatting.hpp | 23 +++++++++++++---------- VTIL-Common/util/range.hpp | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/VTIL-Common/io/formatting.hpp b/VTIL-Common/io/formatting.hpp index 26ae687..1fe2924 100644 --- a/VTIL-Common/io/formatting.hpp +++ b/VTIL-Common/io/formatting.hpp @@ -260,7 +260,7 @@ namespace vtil::format if constexpr ( StringConvertible ) { std::string items = {}; - for ( auto& entry : x ) + for ( auto&& entry : x ) items += as_string( entry ) + ", "; if ( !items.empty() ) items.resize( items.size() - 2 ); return "{" + items + "}"; @@ -391,15 +391,18 @@ namespace vtil::format // Convert fields in each entry into string. // - std::vector> string_entries( entry_count ); - for ( auto [output, entry] : zip( string_entries, data_source ) ) - { - make_constant_series( [ & ] ( auto tag ) - { - auto at = []( auto&& x ) -> auto& { return std::get( x ); }; - output[ decltype( tag )::value ] = as_string( at( entry ) ); - } ); - } + std::vector> string_entries; + string_entries.reserve( entry_count ); + + for ( auto eit = std::begin( data_source ); eit != std::end( data_source ); eit++ ) + { + auto& output = string_entries.emplace_back(); + make_constant_series( [ & ] ( auto tag ) + { + auto at = []( auto&& x ) -> auto& { return std::get( x ); }; + output[ decltype( tag )::value ] = as_string( at( *eit ) ); + } ); + } // Determine field lengths. // diff --git a/VTIL-Common/util/range.hpp b/VTIL-Common/util/range.hpp index 5dec4d9..cb79290 100644 --- a/VTIL-Common/util/range.hpp +++ b/VTIL-Common/util/range.hpp @@ -107,7 +107,7 @@ namespace vtil }; } template - static constexpr auto view_transformed( C&& container, Fn&& f ) + static constexpr auto make_view( C&& container, Fn&& f ) { return impl::range_proxy{ std::forward( f ),