From eba984303c3d7b4c48a9e4c85fee4f41198d886d Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 25 Dec 2019 14:12:17 -0500 Subject: [PATCH] TranslatableString::Format is aware of std::reference_wrapper --- include/audacity/Types.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/audacity/Types.h b/include/audacity/Types.h index 4a9319566..144773533 100644 --- a/include/audacity/Types.h +++ b/include/audacity/Types.h @@ -501,6 +501,13 @@ private: template< typename T > static const T &TranslateArgument( const T &arg, bool ) { return arg; } + // This allows you to wrap arguments of Format in std::cref so that they + // are captured (as if) by reference rather than by value + template< typename T > static auto TranslateArgument( + const std::reference_wrapper &arg, bool debug ) + -> decltype( + TranslatableString::TranslateArgument( arg.get(), debug ) ) + { return TranslatableString::TranslateArgument( arg.get(), debug ); } static wxString TranslateArgument( const TranslatableString &arg, bool debug ) { return arg.DoFormat( debug ); }