1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 09:20:16 +01:00

Define and use utilities transform_range, transform_container

This commit is contained in:
Paul Licameli
2019-02-25 12:50:33 -05:00
parent b0738f6e09
commit 52642e49a5
4 changed files with 29 additions and 25 deletions

View File

@@ -1152,22 +1152,17 @@ namespace {
Array GetTypedTracks(const TrackRange &trackRange,
bool selectionOnly, bool includeMuted)
{
Array array;
using Type = typename
std::remove_reference< decltype( *array[0] ) >::type;
using Type = typename std::remove_reference<
decltype( *std::declval<Array>()[0] )
>::type;
auto subRange =
trackRange.template Filter<Type>();
if ( selectionOnly )
subRange = subRange + &Track::IsSelected;
if ( ! includeMuted )
subRange = subRange - &Type::GetMute;
std::transform(
subRange.begin(), subRange.end(), std::back_inserter( array ),
[]( Type *t ){ return Track::Pointer<Type>( t ); }
);
return array;
return transform_range<Array>( subRange.begin(), subRange.end(),
[]( Type *t ){ return Track::Pointer<Type>( t ); } );
}
}