Fixing reference-to-reference issues.

This commit is contained in:
Can Bölük 2020-08-28 06:49:49 +02:00
parent 2f454199ed
commit 54024217a5
2 changed files with 14 additions and 11 deletions

View file

@ -260,7 +260,7 @@ namespace vtil::format
if constexpr ( StringConvertible<decltype( *std::begin( x ) )> )
{
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<std::array<std::string, field_count>> string_entries( entry_count );
for ( auto [output, entry] : zip( string_entries, data_source ) )
{
make_constant_series<field_count>( [ & ] ( auto tag )
{
auto at = []( auto&& x ) -> auto& { return std::get<decltype( tag )::value>( x ); };
output[ decltype( tag )::value ] = as_string( at( entry ) );
} );
}
std::vector<std::array<std::string, field_count>> 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<field_count>( [ & ] ( auto tag )
{
auto at = []( auto&& x ) -> auto& { return std::get<decltype( tag )::value>( x ); };
output[ decltype( tag )::value ] = as_string( at( *eit ) );
} );
}
// Determine field lengths.
//

View file

@ -107,7 +107,7 @@ namespace vtil
};
}
template<Iterable C, typename Fn>
static constexpr auto view_transformed( C&& container, Fn&& f )
static constexpr auto make_view( C&& container, Fn&& f )
{
return impl::range_proxy<decltype( std::begin( container ) ), Fn>{
std::forward<Fn>( f ),