diff --git a/include/audacity/Types.h b/include/audacity/Types.h index e8ac9656a..bf8ebf3c2 100644 --- a/include/audacity/Types.h +++ b/include/audacity/Types.h @@ -45,6 +45,7 @@ #include #include #include +#include // ---------------------------------------------------------------------------- // TODO: I'd imagine this header may be replaced by other public headers. But, @@ -90,7 +91,7 @@ public: size_t as_size_t() const { wxASSERT(value >= 0); - wxASSERT(value <= std::numeric_limits::max()); + wxASSERT(static_cast::type>(value) <= std::numeric_limits::max()); return value; } diff --git a/src/AboutDialog.cpp b/src/AboutDialog.cpp index f5578e3bd..3fdc22ee5 100644 --- a/src/AboutDialog.cpp +++ b/src/AboutDialog.cpp @@ -986,11 +986,7 @@ wxT("POSSIBILITY OF SUCH DAMAGES.\n")); void AboutDialog::AddCredit(wxString &&description, Role role) { -#ifdef __AUDACITY_OLD_STD__ - creditItems.push_back(AboutDialogCreditItem{ std::move(description), role }); -#else creditItems.emplace_back(std::move(description), role); -#endif } wxString AboutDialog::GetCreditsByRole(AboutDialog::Role role) diff --git a/src/AboutDialog.h b/src/AboutDialog.h index 932733cb0..f3c8d0b9c 100644 --- a/src/AboutDialog.h +++ b/src/AboutDialog.h @@ -32,14 +32,9 @@ struct AboutDialogCreditItem { : description(description_), role(role_) {} -#ifdef __AUDACITY_OLD_STD__ - AboutDialogCreditItem(const AboutDialogCreditItem&) = default; - AboutDialogCreditItem& operator= (const AboutDialogCreditItem&) = default; -#else // No copy, use the move AboutDialogCreditItem(const AboutDialogCreditItem&) PROHIBITED; AboutDialogCreditItem& operator= (const AboutDialogCreditItem&) PROHIBITED; -#endif // Move constructor, because wxString lacks one AboutDialogCreditItem(AboutDialogCreditItem &&moveMe) diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index 42da742d3..58ef81a9e 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -1083,7 +1083,7 @@ bool AudacityApp::OnExceptionInMainLoop() // Use CallAfter to delay this to the next pass of the event loop, // rather than risk doing it inside stack unwinding. auto pProject = ::GetActiveProject(); - std::shared_ptr< AudacityException > pException { e.Move().release() }; + auto pException = std::current_exception(); CallAfter( [=] // Capture pException by value! { @@ -1097,7 +1097,9 @@ bool AudacityApp::OnExceptionInMainLoop() pProject->RedrawProject(); // Give the user an alert - pException->DelayedHandlerAction(); + try { std::rethrow_exception( pException ); } + catch( AudacityException &e ) + { e.DelayedHandlerAction(); } } ); diff --git a/src/AudacityException.cpp b/src/AudacityException.cpp index deb9e9424..4a8b18229 100644 --- a/src/AudacityException.cpp +++ b/src/AudacityException.cpp @@ -85,12 +85,6 @@ wxString SimpleMessageBoxException::ErrorMessage() const return message; } -std::unique_ptr< AudacityException > SimpleMessageBoxException::Move() -{ - return std::unique_ptr< AudacityException > - { safenew SimpleMessageBoxException{ std::move( *this ) } }; -} - // This is meant to be invoked via wxEvtHandler::CallAfter void MessageBoxException::DelayedHandlerAction() { diff --git a/src/AudacityException.h b/src/AudacityException.h index 8d86dcc0e..f8662a40b 100644 --- a/src/AudacityException.h +++ b/src/AudacityException.h @@ -30,11 +30,6 @@ public: AudacityException() {} virtual ~AudacityException() = 0; - // This is intended as a "polymorphic move copy constructor" - // which leaves this "empty". - // We would not need this if we had std::exception_ptr - virtual std::unique_ptr< AudacityException > Move() = 0; - // Action to do in the main thread at idle time of the event loop. virtual void DelayedHandlerAction() = 0; @@ -88,8 +83,6 @@ public: SimpleMessageBoxException &operator = ( SimpleMessageBoxException && ) PROHIBITED; - std::unique_ptr< AudacityException > Move() override; - // Format a default, internationalized error message for this exception. virtual wxString ErrorMessage() const override; @@ -170,11 +163,15 @@ R GuardedCall catch ( AudacityException &e ) { auto end = finally([&]{ + // At this point, e is the "current" exception, but not "uncaught" + // unless it was rethrown by handler. handler might also throw some + // other exception object. if (!std::uncaught_exception()) { - auto pException = - std::shared_ptr< AudacityException > { e.Move().release() }; + auto pException = std::current_exception(); // This points to e wxTheApp->CallAfter( [=] { // capture pException by value - delayedHandler( pException.get() ); + try { std::rethrow_exception(pException); } + catch( AudacityException &e ) + { delayedHandler( &e ); } } ); } }); diff --git a/src/AutoRecovery.h b/src/AutoRecovery.h index 1a6949d0d..622de746e 100644 --- a/src/AutoRecovery.h +++ b/src/AutoRecovery.h @@ -21,9 +21,7 @@ #include #include -#ifndef __AUDACITY_OLD_STD__ #include -#endif // // Show auto recovery dialog if there are projects to recover. Should be diff --git a/src/BlockFile.h b/src/BlockFile.h index 8a400bb41..5d5e0808d 100644 --- a/src/BlockFile.h +++ b/src/BlockFile.h @@ -180,7 +180,7 @@ class PROFILE_DLL_API BlockFile /* not final, abstract */ { struct ReadUnlocker { void operator () ( const BlockFile *p ) const { if (p) p->UnlockRead(); } }; using ReadLockBase = - movable_ptr_with_deleter< const BlockFile, ReadUnlocker >; + std::unique_ptr< const BlockFile, ReadUnlocker >; public: class ReadLock : public ReadLockBase @@ -189,14 +189,6 @@ class PROFILE_DLL_API BlockFile /* not final, abstract */ { ReadLock ( const BlockFile *p, const BlockFile::ReadUnlocker &u ) : ReadLockBase { p, u } {} public: -#ifdef __AUDACITY_OLD_STD__ - ReadLock (const ReadLock &that) : ReadLockBase( that ) {} - ReadLock &operator= (const ReadLock &that) - { - *((ReadLockBase*)this) = that; - return *this; - } -#endif ReadLock(ReadLock&&that) : ReadLockBase{ std::move(that) } {} using Suspension = std::unique_ptr< const BlockFile, ReadLocker >; Suspension Suspend() const diff --git a/src/Dependencies.cpp b/src/Dependencies.cpp index 179d114e4..0c66e1e62 100644 --- a/src/Dependencies.cpp +++ b/src/Dependencies.cpp @@ -58,9 +58,7 @@ AliasedFile s. #include "WaveClip.h" #include "widgets/ErrorDialog.h" -#ifndef __AUDACITY_OLD_STD__ #include -#endif using AliasedFileHash = std::unordered_map; diff --git a/src/DirManager.h b/src/DirManager.h index 0d70a67b8..67fbed234 100644 --- a/src/DirManager.h +++ b/src/DirManager.h @@ -22,9 +22,7 @@ #include "xml/XMLTagHandler.h" #include "wxFileNameWrapper.h" -#ifndef __AUDACITY_OLD_STD__ #include -#endif class wxHashTable; class BlockArray; diff --git a/src/FileException.cpp b/src/FileException.cpp index 21c63ef62..b9bdfccd7 100644 --- a/src/FileException.cpp +++ b/src/FileException.cpp @@ -15,12 +15,6 @@ FileException::~FileException() { } -std::unique_ptr< AudacityException > FileException::Move() -{ - return std::unique_ptr< AudacityException > - { safenew FileException{ std::move( *this ) } }; -} - wxString FileException::ErrorMessage() const { wxString format; diff --git a/src/FileException.h b/src/FileException.h index 6a6fcb6ec..9f624be63 100644 --- a/src/FileException.h +++ b/src/FileException.h @@ -37,8 +37,6 @@ public: ~FileException() override; protected: - std::unique_ptr< AudacityException > Move() override; - // Format a default, internationalized error message for this exception. wxString ErrorMessage() const override; diff --git a/src/InconsistencyException.cpp b/src/InconsistencyException.cpp index 73db17a6b..33cdc5292 100644 --- a/src/InconsistencyException.cpp +++ b/src/InconsistencyException.cpp @@ -14,12 +14,6 @@ InconsistencyException::~InconsistencyException() { } -std::unique_ptr< AudacityException > InconsistencyException::Move() -{ - return std::unique_ptr< AudacityException > - { safenew InconsistencyException{ std::move( *this ) } }; -} - wxString InconsistencyException::ErrorMessage() const { // Shorten the path diff --git a/src/InconsistencyException.h b/src/InconsistencyException.h index 2012203fe..78477b263 100644 --- a/src/InconsistencyException.h +++ b/src/InconsistencyException.h @@ -48,8 +48,6 @@ public: unsigned GetLine() const { return line; } private: - std::unique_ptr< AudacityException > Move() override; - // Format a default, internationalized error message for this exception. wxString ErrorMessage() const override; diff --git a/src/Languages.cpp b/src/Languages.cpp index 88d0d9ff6..ba8891aac 100644 --- a/src/Languages.cpp +++ b/src/Languages.cpp @@ -42,9 +42,7 @@ #include "AudacityApp.h" -#ifndef __AUDACITY_OLD_STD__ #include -#endif using LangHash = std::unordered_map; diff --git a/src/MemoryX.h b/src/MemoryX.h index 5feb3a366..a68eecf83 100644 --- a/src/MemoryX.h +++ b/src/MemoryX.h @@ -13,410 +13,8 @@ #undef __AUDACITY_OLD_STD__ -// JKC: -// This is completely the wrong way to test for new stdlib (supporting std::hash etc) -// We should instead use configure checks or test if __cplusplus is bigger that some value. -// -// On the other hand, as we are moving to wxWidgets 3.1.1, macOSX 10.7+ is required. -// And we could just assume/require building with C++11 and remove the body of this -// ifdef - i.e. no longer support those workarounds. -// -// Macports have provided some really useful information about possibilities for -// building with newer compilers and older SDKs. So the option of building with old -// compilers and old SDKs may not be needed at all, making the shift to requiring -// C++11 have little to no downside. So as of 13th April 2018 the code in this -// ifdef's days are numbered. -#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED <= __MAC_10_6 - -#define __AUDACITY_OLD_STD__ - -#include -inline long long int llrint(float __x) { return __builtin_llrintf(__x); } -inline long long int llrint(double __x) { return __builtin_llrintl(__x); } -inline long long int llrint(long double __x) { return __builtin_llrintl(__x); } - -#include -using std::isnan; -using std::isinf; - -// Need this to define move() and forward() -#include - -// To define make_shared -#include - -// To define function -#include - -// To define unordered_set -#include - -// To define unordered_map and hash -#include - -#include - -namespace std { - using std::tr1::unordered_set; - using std::tr1::hash; - using std::tr1::unordered_map; - using std::tr1::function; - using std::tr1::shared_ptr; - using std::tr1::weak_ptr; - using std::tr1::static_pointer_cast; - using std::tr1::remove_reference; - using std::tr1::is_unsigned; - using std::tr1::is_const; - using std::tr1::add_const; - using std::tr1::add_pointer; - using std::tr1::remove_pointer; - using std::tr1::tuple; - using std::tr1::get; - - template struct add_rvalue_reference { - using type = T&&; - }; - - template struct default_delete - { - default_delete() {} - - // Allow copy from other deleter classes - template - default_delete(const default_delete& that) - { - // Break compilation if Y* does not convert to X* - // I should figure out the right use of enable_if instead - // Note: YPtr avoids bogus compiler warning for C99 compound literals - using YPtr = Y*; - static_assert((static_cast(YPtr{}), true), - "Pointer types not convertible"); - } - - inline void operator() (void *p) const - { - delete static_cast(p); - } - }; - - // Specialization for arrays - template struct default_delete - { - // Do not allow copy from other deleter classes - inline void operator() (void *p) const - { - delete[] static_cast(p); - } - }; - - struct nullptr_t - { - void* __lx; - - struct __nat {int __for_bool_;}; - - nullptr_t() : __lx(0) {} - nullptr_t(int __nat::*) : __lx(0) {} - - operator int __nat::*() const {return 0;} - - template - operator _Tp* () const {return 0;} - - template - operator _Tp _Up::* () const {return 0;} - - friend bool operator==(nullptr_t, nullptr_t) {return true;} - friend bool operator!=(nullptr_t, nullptr_t) {return false;} - friend bool operator<(nullptr_t, nullptr_t) {return false;} - friend bool operator<=(nullptr_t, nullptr_t) {return true;} - friend bool operator>(nullptr_t, nullptr_t) {return false;} - friend bool operator>=(nullptr_t, nullptr_t) {return true;} - }; - - inline nullptr_t __get_nullptr_t() {return nullptr_t(0);} - - #define nullptr std::__get_nullptr_t() - - // "Cast" anything as an rvalue reference. - template inline typename remove_reference::type&& move(T&& t) - { return static_cast::type&&>(t); } - - template> class unique_ptr - : private D // use empty base optimization - { - public: - // Default constructor - unique_ptr() {} - - // Implicit constrution from nullptr - unique_ptr(nullptr_t) {} - - // Explicit constructor from pointer and optional deleter - explicit unique_ptr(T *p_) - : p{ p_ } {} - explicit unique_ptr(T *p_, const D &d) - : D(d), p{ p_ } {} - // Template constructors for upcasting - template - explicit unique_ptr(U* p_) - : p{ p_ } {} - template - explicit unique_ptr(U* p_, const D& d) - : D(d), p{ p_ } {} - - // Copy is disallowed - unique_ptr(const unique_ptr &) PROHIBITED; - unique_ptr& operator= (const unique_ptr &) PROHIBITED; - - // But move is allowed! - unique_ptr(unique_ptr &&that) - : D(move(that.get_deleter())), p{ that.release() } { } - unique_ptr& operator= (unique_ptr &&that) - { - if (this != &that) { - get_deleter()(p); - ((D&)*this) = move(that.get_deleter()); - p = that.release(); - } - return *this; - } - - // Assign null - unique_ptr& operator= (nullptr_t) - { - get_deleter()(p); - p = nullptr; - return *this; - } - - // Template versions of move for upcasting - template - unique_ptr(unique_ptr &&that) - : D(move(that.get_deleter())), p{ that.release() } { } - template - unique_ptr& operator= (unique_ptr &&that) - { - // Skip the self-assignment test -- self-assignment should go to the non-template overload - get_deleter()(p); - p = that.release(); - get_deleter() = move(that.get_deleter()); - return *this; - } - - D& get_deleter() { return *this; } - const D& get_deleter() const { return *this; } - - ~unique_ptr() { get_deleter()(p); } - - T* operator -> () const { return p; } - T& operator * () const { return *p; } - T* get() const { return p; } - - // So you can say if(p) - explicit operator bool() const { return p != nullptr; } - - // Give up ownership, don't destroy - T* release() { T* result = p; p = nullptr; return result; } - - void reset(T* __p = nullptr) - { - T* old__p = p; - p = __p; - if (old__p != nullptr) - { - get_deleter()(old__p); - } - } - - void swap(unique_ptr& that) - { - std::swap(p, that.p); - std::swap(get_deleter(), that.get_deleter()); - } - - private: - T *p{}; - }; - - // Now specialize the class for array types - template class unique_ptr - : private D // use empty base optimization - { - public: - // Default constructor - unique_ptr() {} - - // Implicit constrution from nullptr - unique_ptr(nullptr_t) {} - - // Explicit constructor from pointer - explicit unique_ptr(T *p_) - : p{ p_ } {} - explicit unique_ptr(T *p_, const D &d) - : D( d ), p{ p_ } {} - // NO template constructor for upcasting! - - // Copy is disallowed - unique_ptr(const unique_ptr &) PROHIBITED; - unique_ptr& operator= (const unique_ptr &)PROHIBITED; - - // But move is allowed! - unique_ptr(unique_ptr &&that) - : D( move(that.get_deleter()) ), p{ that.release() } { } - unique_ptr& operator= (unique_ptr &&that) - { - if (this != &that) { - get_deleter()(p); - p = that.release(); - ((D&)*this) = move(that.get_deleter()); - } - return *this; - } - - // Assign null - unique_ptr& operator= (nullptr_t) - { - get_deleter()(p); - p = nullptr; - return *this; - } - - D& get_deleter() { return *this; } - const D& get_deleter() const { return *this; } - - // NO template versions of move for upcasting! - - ~unique_ptr() { get_deleter()(p); } - - // No operator ->, but [] instead - T& operator [] (size_t n) const { return p[n]; } - - T& operator * () const { return *p; } - T* get() const { return p; } - - // So you can say if(p) - explicit operator bool() const { return p != nullptr; } - - // Give up ownership, don't destroy - T* release() { T* result = p; p = nullptr; return result; } - - void reset(T* __p = nullptr) - { - T* old__p = p; - p = __p; - if (old__p != nullptr) - { - get_deleter()(old__p); - } - } - - void swap(unique_ptr& that) - { - std::swap(p, that.p); - std::swap(get_deleter(), that.get_deleter()); - } - - private: - T *p{}; - }; - - // Equality operators for unique_ptr, don't need the specializations for array case - template - inline bool operator== (nullptr_t, const unique_ptr& ptr) - { - return ptr.get() == nullptr; - } - template - inline bool operator== (const unique_ptr& ptr, nullptr_t) - { - return ptr.get() == nullptr; - } - template - inline bool operator == (const unique_ptr &ptr1, - const unique_ptr &ptr2) - { - return ptr1.get() == ptr2.get(); - } - - template inline bool operator != (nullptr_t, const unique_ptr &ptr) { return !(ptr == nullptr); } - template inline bool operator != (const unique_ptr &ptr, nullptr_t) { return !(ptr == nullptr); } - template inline bool operator != (const unique_ptr& ptr1, const unique_ptr &ptr2) - { return !(ptr1 == ptr2); } - - // Forward -- pass along rvalue references as rvalue references, anything else as it is - // (Because the appropriate overload is taken, and "reference collapse" applies to the return type) - template inline T&& forward(typename remove_reference::type& t) - { return static_cast(t); } - template inline T&& forward(typename remove_reference::type&& t) - { return static_cast(t); } - - // Declared but never defined, and typically used in decltype constructs - template - typename std::add_rvalue_reference::type declval() //noexcept - ; - - // We need make_shared for ourselves, because the library doesn't use variadics - template inline shared_ptr make_shared(Args&&... args) - { - return shared_ptr{ safenew X(forward(args)...) }; - } - // From LLVM c++11 and modified - - #include - - template - class initializer_list - { - const _Ep* __begin_; - size_t __size_; - - initializer_list(const _Ep* __b, size_t __s) - : __begin_(__b), - __size_(__s) - {} - public: - typedef _Ep value_type; - typedef const _Ep& reference; - typedef const _Ep& const_reference; - typedef size_t size_type; - - typedef const _Ep* iterator; - typedef const _Ep* const_iterator; - - initializer_list() : __begin_(nullptr), __size_(0) {} - - size_t size() const {return __size_;} - - const _Ep* begin() const {return __begin_;} - - const _Ep* end() const {return __begin_ + __size_;} - }; - - template - inline - const _Ep* - begin(initializer_list<_Ep> __il) - { - return __il.begin(); - } - - template - inline - const _Ep* - end(initializer_list<_Ep> __il) - { - return __il.end(); - } -} - -#else - -// To define function #include -#endif - #if !(_MSC_VER >= 1800 || __cplusplus >= 201402L) /* replicate the very useful C++14 make_unique for those build environments that don't implement it yet. @@ -1185,27 +783,20 @@ make_value_transform_iterator(const Iterator &iterator, Function function) return { iterator, NewFunction{ function } }; } +#if !wxCHECK_VERSION(3, 1, 0) // For using std::unordered_map on wxString namespace std { -#ifdef __AUDACITY_OLD_STD__ - namespace tr1 - { -#endif -#if !wxCHECK_VERSION(3, 1, 0) - template struct hash; - template<> struct hash< wxString > { - size_t operator () (const wxString &str) const // noexcept - { - auto stdstr = str.ToStdWstring(); // no allocations, a cheap fetch - using Hasher = hash< decltype(stdstr) >; - return Hasher{}( stdstr ); - } - }; -#endif -#ifdef __AUDACITY_OLD_STD__ - } -#endif + template struct hash; + template<> struct hash< wxString > { + size_t operator () (const wxString &str) const // noexcept + { + auto stdstr = str.ToStdWstring(); // no allocations, a cheap fetch + using Hasher = hash< decltype(stdstr) >; + return Hasher{}( stdstr ); + } + }; } +#endif #endif // __AUDACITY_MEMORY_X_H__ diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index 2e41a36ea..b0b788d1d 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -1437,7 +1437,7 @@ void MixerBoard::LoadMusicalInstruments() auto bmp = std::make_unique(data.bitmap); dc.SelectObject(*bmp); AColor::Bevel(dc, false, bev); - mMusicalInstruments.push_back(make_movable( + mMusicalInstruments.push_back(std::make_unique( std::move(bmp), data.name )); }; diff --git a/src/MixerBoard.h b/src/MixerBoard.h index e305e5740..b90503f5e 100644 --- a/src/MixerBoard.h +++ b/src/MixerBoard.h @@ -163,7 +163,7 @@ public: wxArrayString mKeywords; }; -using MusicalInstrumentArray = std::vector>; +using MusicalInstrumentArray = std::vector>; diff --git a/src/ModuleManager.cpp b/src/ModuleManager.cpp index d15ec24eb..62bec1bcc 100755 --- a/src/ModuleManager.cpp +++ b/src/ModuleManager.cpp @@ -287,7 +287,7 @@ void ModuleManager::Initialize(CommandHandler &cmdHandler) ModulePrefs::SetModuleStatus( files[i], kModuleFailed ); #endif - auto umodule = make_movable(files[i]); + auto umodule = std::make_unique(files[i]); if (umodule->Load()) // it will get rejected if there are version problems { auto module = umodule.get(); @@ -421,7 +421,7 @@ void ModuleManager::InitializeBuiltins() ModuleInterface *ModuleManager::LoadModule(const wxString & path) { - auto lib = make_movable(); + auto lib = std::make_unique(); if (lib->Load(path, wxDL_NOW)) { diff --git a/src/ModuleManager.h b/src/ModuleManager.h index 3737d4ee3..16a412c15 100644 --- a/src/ModuleManager.h +++ b/src/ModuleManager.h @@ -66,13 +66,13 @@ struct ModuleInterfaceDeleter { void operator ()(ModuleInterface *pInterface) const; }; -using ModuleInterfaceHandle = movable_ptr_with_deleter< +using ModuleInterfaceHandle = std::unique_ptr< ModuleInterface, ModuleInterfaceDeleter >; typedef std::map ModuleMainMap; typedef std::map ModuleMap; -typedef std::map> LibraryMap; +typedef std::map> LibraryMap; class ModuleManager final : public ModuleManagerInterface { @@ -126,7 +126,7 @@ private: ModuleMap mDynModules; LibraryMap mLibs; - std::vector> mModules; + std::vector> mModules; }; #endif /* __AUDACITY_MODULEMANAGER_H__ */ diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index d9653b4fe..f476b4b4d 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -56,9 +56,7 @@ for shared and private configs - which need to move out. #include "Experimental.h" -#ifndef __AUDACITY_OLD_STD__ #include -#endif using ProviderMap = std::unordered_map; diff --git a/src/Profiler.cpp b/src/Profiler.cpp index fc3659fe4..c1fa8c183 100644 --- a/src/Profiler.cpp +++ b/src/Profiler.cpp @@ -96,7 +96,7 @@ TaskProfile* Profiler::GetOrCreateTaskProfile(const char* fileName, int lineNum) return mTasks[i].get(); } - auto tp = make_movable(); + auto tp = std::make_unique(); mTasks.push_back(std::move(tp)); return mTasks.back().get(); } diff --git a/src/Profiler.h b/src/Profiler.h index 9516bd2d0..41f3586a6 100644 --- a/src/Profiler.h +++ b/src/Profiler.h @@ -60,7 +60,7 @@ class Profiler TaskProfile* GetTaskProfileByDescription(const char* description); //List of current Task to do. - std::vector> mTasks; + std::vector> mTasks; //mutex for above variable ODLock mTasksMutex; diff --git a/src/Project.cpp b/src/Project.cpp index 665cc67dd..44c16bc7a 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -3402,7 +3402,7 @@ void AudacityProject::EnqueueODTasks() TrackListIterator triter(GetTracks()); tr = triter.First(); - std::vector> newTasks; + std::vector> newTasks; //std::vector decodeTasks; unsigned int createdODTasks=0; while (tr) { @@ -3422,16 +3422,16 @@ void AudacityProject::EnqueueODTasks() //we want at most one instance of each class for the project while((odFlags|createdODTasks) != createdODTasks) { - movable_ptr newTask; + std::unique_ptr newTask; #ifdef EXPERIMENTAL_OD_FLAC if(!(createdODTasks&ODTask::eODFLAC) && (odFlags & ODTask::eODFLAC)) { - newTask = make_movable(); + newTask = std::make_unique(); createdODTasks = createdODTasks | ODTask::eODFLAC; } else #endif if(!(createdODTasks&ODTask::eODPCMSummary) && (odFlags & ODTask::eODPCMSummary)) { - newTask = make_movable(); + newTask = std::make_unique(); createdODTasks= createdODTasks | ODTask::eODPCMSummary; } else { @@ -4039,7 +4039,7 @@ bool AudacityProject::DoSave // (Otherwise the NEW project would be fine, but the old one would // be empty of all of its files.) - std::vector> lockers; + std::vector> lockers; if (mLastSavedTracks) { lockers.reserve(mLastSavedTracks->size()); TrackListIterator iter(mLastSavedTracks.get()); @@ -4047,7 +4047,7 @@ bool AudacityProject::DoSave while (t) { if (t->GetKind() == Track::Wave) lockers.push_back( - make_movable( + std::make_unique( static_cast(t))); t = iter.Next(); } @@ -4666,7 +4666,7 @@ void AudacityProject::PopState(const UndoState &state) TrackListIterator iter(tracks); Track *t = iter.First(); bool odUsed = false; - movable_ptr computeTask; + std::unique_ptr computeTask; while (t) { @@ -4686,7 +4686,7 @@ void AudacityProject::PopState(const UndoState &state) { if(!odUsed) { - computeTask = make_movable(); + computeTask = std::make_unique(); odUsed=true; } // PRL: Is it correct to add all tracks to one task, even if they diff --git a/src/RealFFTf.cpp b/src/RealFFTf.cpp index c85f3f2e1..c457a62eb 100644 --- a/src/RealFFTf.cpp +++ b/src/RealFFTf.cpp @@ -102,7 +102,7 @@ HFFT InitializeFFT(size_t fftlen) enum : size_t { MAX_HFFT = 10 }; // Maintain a pool: -static std::vector< movable_ptr > hFFTArray(MAX_HFFT); +static std::vector< std::unique_ptr > hFFTArray(MAX_HFFT); wxCriticalSection getFFTMutex; /* Get a handle to the FFT tables of the desired length */ diff --git a/src/Tags.h b/src/Tags.h index 4a62c1fac..415d690d3 100644 --- a/src/Tags.h +++ b/src/Tags.h @@ -41,9 +41,7 @@ #include "widgets/wxPanelWrapper.h" -#ifndef __AUDACITY_OLD_STD__ #include -#endif class wxButton; class wxChoice; diff --git a/src/UndoManager.cpp b/src/UndoManager.cpp index 92ce4826f..9cd0e5d4b 100644 --- a/src/UndoManager.cpp +++ b/src/UndoManager.cpp @@ -36,9 +36,7 @@ UndoManager #include "UndoManager.h" -#ifndef __AUDACITY_OLD_STD__ #include -#endif using ConstBlockFilePtr = const BlockFile*; using Set = std::unordered_set; @@ -290,7 +288,7 @@ void UndoManager::PushState(const TrackList * l, // Assume tags was duplicted before any changes. // Just save a NEW shared_ptr to it. stack.push_back( - make_movable + std::make_unique (std::move(tracksCopy), longDescription, shortDescription, selectedRegion, tags) ); diff --git a/src/UndoManager.h b/src/UndoManager.h index cb53d7547..1356cb198 100644 --- a/src/UndoManager.h +++ b/src/UndoManager.h @@ -72,7 +72,7 @@ struct UndoState { SelectedRegion selectedRegion; // by value }; -using UndoStack = std::vector >; +using UndoStack = std::vector >; using SpaceArray = std::vector ; diff --git a/src/UserException.cpp b/src/UserException.cpp index f26502d14..6229bc5bb 100644 --- a/src/UserException.cpp +++ b/src/UserException.cpp @@ -13,12 +13,6 @@ UserException::~UserException() { } -std::unique_ptr< AudacityException > UserException::Move() -{ - return std::unique_ptr< AudacityException > - { safenew UserException{ std::move( *this ) } }; -} - void UserException::DelayedHandlerAction() { } diff --git a/src/UserException.h b/src/UserException.h index e59b881cc..da0fd7e94 100644 --- a/src/UserException.h +++ b/src/UserException.h @@ -30,9 +30,6 @@ public: ~UserException() override; void DelayedHandlerAction() override; - -private: - std::unique_ptr< AudacityException > Move() override; }; #endif diff --git a/src/WaveClip.cpp b/src/WaveClip.cpp index 795b3cc31..990e34a8c 100644 --- a/src/WaveClip.cpp +++ b/src/WaveClip.cpp @@ -333,7 +333,7 @@ WaveClip::WaveClip(const WaveClip& orig, if ( copyCutlines ) for (const auto &clip: orig.mCutLines) mCutLines.push_back - ( make_movable( *clip, projDirManager, true ) ); + ( std::make_unique( *clip, projDirManager, true ) ); mIsPlaceholder = orig.GetIsPlaceholder(); } @@ -377,7 +377,7 @@ WaveClip::WaveClip(const WaveClip& orig, if (cutlinePosition >= t0 && cutlinePosition <= t1) { auto newCutLine = - make_movable< WaveClip >( *clip, projDirManager, true ); + std::make_unique< WaveClip >( *clip, projDirManager, true ); newCutLine->SetOffset( cutlinePosition - t0 ); mCutLines.push_back(std::move(newCutLine)); } @@ -1552,7 +1552,7 @@ XMLTagHandler *WaveClip::HandleXMLChild(const wxChar *tag) { // Nested wave clips are cut lines mCutLines.push_back( - make_movable(mSequence->GetDirManager(), + std::make_unique(mSequence->GetDirManager(), mSequence->GetSampleFormat(), mRate, 0 /*colourindex*/)); return mCutLines.back().get(); } @@ -1608,7 +1608,7 @@ void WaveClip::Paste(double t0, const WaveClip* other) for (const auto &cutline: pastedClip->mCutLines) { newCutlines.push_back( - make_movable + std::make_unique ( *cutline, mSequence->GetDirManager(), // Recursively copy cutlines of cutlines. They don't need // their offsets adjusted. @@ -1745,7 +1745,7 @@ void WaveClip::ClearAndAddCutLine(double t0, double t1) const double clip_t0 = std::max( t0, GetStartTime() ); const double clip_t1 = std::min( t1, GetEndTime() ); - auto newClip = make_movable< WaveClip > + auto newClip = std::make_unique< WaveClip > (*this, mSequence->GetDirManager(), true, clip_t0, clip_t1); newClip->SetOffset( clip_t0 - mOffset ); diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index 6743068b3..d45c9f74c 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -141,7 +141,7 @@ WaveTrack::WaveTrack(const WaveTrack &orig): for (const auto &clip : orig.mClips) mClips.push_back - ( make_movable( *clip, mDirManager, true ) ); + ( std::make_unique( *clip, mDirManager, true ) ); } // Copy the track metadata but not the contents. @@ -625,7 +625,7 @@ Track::Holder WaveTrack::Copy(double t0, double t1, bool forClipboard) const //wxPrintf("copy: clip %i is in copy region\n", (int)clip); newTrack->mClips.push_back - (make_movable(*clip, mDirManager, ! forClipboard)); + (std::make_unique(*clip, mDirManager, ! forClipboard)); WaveClip *const newClip = newTrack->mClips.back().get(); newClip->Offset(-t0); } @@ -637,7 +637,7 @@ Track::Holder WaveTrack::Copy(double t0, double t1, bool forClipboard) const const double clip_t0 = std::max(t0, clip->GetStartTime()); const double clip_t1 = std::min(t1, clip->GetEndTime()); - auto newClip = make_movable + auto newClip = std::make_unique (*clip, mDirManager, ! forClipboard, clip_t0, clip_t1); //wxPrintf("copy: clip_t0=%f, clip_t1=%f\n", clip_t0, clip_t1); @@ -657,7 +657,7 @@ Track::Holder WaveTrack::Copy(double t0, double t1, bool forClipboard) const if (forClipboard && newTrack->GetEndTime() + 1.0 / newTrack->GetRate() < t1 - t0) { - auto placeholder = make_movable(mDirManager, + auto placeholder = std::make_unique(mDirManager, newTrack->GetSampleFormat(), static_cast(newTrack->GetRate()), 0 /*colourindex*/); @@ -1049,7 +1049,7 @@ void WaveTrack::HandleClear(double t0, double t1, // Don't modify this clip in place, because we want a strong // guarantee, and might modify another clip clipsToDelete.push_back( clip.get() ); - auto newClip = make_movable( *clip, mDirManager, true ); + auto newClip = std::make_unique( *clip, mDirManager, true ); newClip->ClearAndAddCutLine( t0, t1 ); clipsToAdd.push_back( std::move( newClip ) ); } @@ -1064,7 +1064,7 @@ void WaveTrack::HandleClear(double t0, double t1, // Don't modify this clip in place, because we want a strong // guarantee, and might modify another clip clipsToDelete.push_back( clip.get() ); - auto newClip = make_movable( *clip, mDirManager, true ); + auto newClip = std::make_unique( *clip, mDirManager, true ); newClip->Clear(clip->GetStartTime(), t1); newClip->Offset(t1-clip->GetStartTime()); @@ -1076,7 +1076,7 @@ void WaveTrack::HandleClear(double t0, double t1, // Don't modify this clip in place, because we want a strong // guarantee, and might modify another clip clipsToDelete.push_back( clip.get() ); - auto newClip = make_movable( *clip, mDirManager, true ); + auto newClip = std::make_unique( *clip, mDirManager, true ); newClip->Clear(t0, clip->GetEndTime()); clipsToAdd.push_back( std::move( newClip ) ); @@ -1087,12 +1087,12 @@ void WaveTrack::HandleClear(double t0, double t1, // left clipsToAdd.push_back - ( make_movable( *clip, mDirManager, true ) ); + ( std::make_unique( *clip, mDirManager, true ) ); clipsToAdd.back()->Clear(t0, clip->GetEndTime()); // right clipsToAdd.push_back - ( make_movable( *clip, mDirManager, true ) ); + ( std::make_unique( *clip, mDirManager, true ) ); WaveClip *const right = clipsToAdd.back().get(); right->Clear(clip->GetStartTime(), t1); right->Offset(t1 - clip->GetStartTime()); @@ -1106,7 +1106,7 @@ void WaveTrack::HandleClear(double t0, double t1, // Don't modify this clip in place, because we want a strong // guarantee, and might modify another clip clipsToDelete.push_back( clip.get() ); - auto newClip = make_movable( *clip, mDirManager, true ); + auto newClip = std::make_unique( *clip, mDirManager, true ); // clip->Clear keeps points < t0 and >= t1 via Envelope::CollapseRegion newClip->Clear(t0,t1); @@ -1339,7 +1339,7 @@ void WaveTrack::Paste(double t0, const Track *src) if (!clip->GetIsPlaceholder()) { auto newClip = - make_movable( *clip, mDirManager, true ); + std::make_unique( *clip, mDirManager, true ); newClip->Resample(mRate); newClip->Offset(t0); newClip->MarkChanged(); @@ -1395,7 +1395,7 @@ void WaveTrack::InsertSilence(double t, double len) if (mClips.empty()) { // Special case if there is no clip yet - auto clip = make_movable(mDirManager, mFormat, mRate, this->GetWaveColorIndex()); + auto clip = std::make_unique(mDirManager, mFormat, mRate, this->GetWaveColorIndex()); clip->InsertSilence(0, len); // use NOFAIL-GUARANTEE mClips.push_back( std::move( clip ) ); @@ -2228,7 +2228,7 @@ Sequence* WaveTrack::GetSequenceAtX(int xcoord) WaveClip* WaveTrack::CreateClip() { - mClips.push_back(make_movable(mDirManager, mFormat, mRate, GetWaveColorIndex())); + mClips.push_back(std::make_unique(mDirManager, mFormat, mRate, GetWaveColorIndex())); return mClips.back().get(); } @@ -2388,7 +2388,7 @@ void WaveTrack::SplitAt(double t) if (c->WithinClip(t)) { t = LongSamplesToTime(TimeToLongSamples(t)); // put t on a sample - auto newClip = make_movable( *c, mDirManager, true ); + auto newClip = std::make_unique( *c, mDirManager, true ); c->Clear(t, c->GetEndTime()); newClip->Clear(c->GetStartTime(), t); diff --git a/src/blockfile/NotYetAvailableException.cpp b/src/blockfile/NotYetAvailableException.cpp index 0d01275dc..356534bd9 100644 --- a/src/blockfile/NotYetAvailableException.cpp +++ b/src/blockfile/NotYetAvailableException.cpp @@ -14,12 +14,6 @@ NotYetAvailableException::~NotYetAvailableException() { } -std::unique_ptr< AudacityException > NotYetAvailableException::Move() -{ - return std::unique_ptr< AudacityException > - { safenew NotYetAvailableException{ std::move( *this ) } }; -} - wxString NotYetAvailableException::ErrorMessage() const { return wxString::Format( diff --git a/src/blockfile/NotYetAvailableException.h b/src/blockfile/NotYetAvailableException.h index d961bcec7..cc375c15c 100644 --- a/src/blockfile/NotYetAvailableException.h +++ b/src/blockfile/NotYetAvailableException.h @@ -25,7 +25,6 @@ public: ~NotYetAvailableException(); protected: - std::unique_ptr< AudacityException > Move() override; wxString ErrorMessage() const override; }; diff --git a/src/commands/AudacityCommand.cpp b/src/commands/AudacityCommand.cpp index 39a2e690a..b1d7fd6e4 100644 --- a/src/commands/AudacityCommand.cpp +++ b/src/commands/AudacityCommand.cpp @@ -59,9 +59,7 @@ ShuttleGui. #include "../Experimental.h" #include "../commands/ScreenshotCommand.h" -#ifndef __AUDACITY_OLD_STD__ #include -#endif #include "../commands/CommandContext.h" AudacityCommand::AudacityCommand() diff --git a/src/commands/BatchEvalCommand.cpp b/src/commands/BatchEvalCommand.cpp index 255e57deb..f943f1d02 100644 --- a/src/commands/BatchEvalCommand.cpp +++ b/src/commands/BatchEvalCommand.cpp @@ -24,11 +24,11 @@ IdentInterfaceSymbol BatchEvalCommandType::BuildName() void BatchEvalCommandType::BuildSignature(CommandSignature &signature) { - auto commandNameValidator = make_movable(); + auto commandNameValidator = std::make_unique(); signature.AddParameter(wxT("CommandName"), wxT(""), std::move(commandNameValidator)); - auto paramValidator = make_movable(); + auto paramValidator = std::make_unique(); signature.AddParameter(wxT("ParamString"), wxT(""), std::move(paramValidator)); - auto macroValidator = make_movable(); + auto macroValidator = std::make_unique(); signature.AddParameter(wxT("MacroName"), wxT(""), std::move(macroValidator)); } diff --git a/src/commands/CommandDirectory.cpp b/src/commands/CommandDirectory.cpp index a22b324c1..5382f907f 100644 --- a/src/commands/CommandDirectory.cpp +++ b/src/commands/CommandDirectory.cpp @@ -28,38 +28,38 @@ CommandDirectory::CommandDirectory() { // Create the command map. // First we have commands which return information - //AddCommand(make_movable()); - AddCommand(make_movable()); + //AddCommand(std::make_unique()); + AddCommand(std::make_unique()); // Legacy adapter commands that previously was needed to // access menu items. - //AddCommand(make_movable()); + //AddCommand(std::make_unique()); // Not needed. Sets selected/solo/mute on multiple tracks. - //AddCommand(make_movable()); + //AddCommand(std::make_unique()); // Moved to AudacityCommand -// AddCommand(make_movable()); -// AddCommand(make_movable()); -// AddCommand(make_movable()); -// AddCommand(make_movable()); -// AddCommand(make_movable()); -// AddCommand(make_movable("GetAll")); -// AddCommand(make_movable("GetCommands")); -// AddCommand(make_movable("GetMenus")); -// AddCommand(make_movable("GetMenusPlus")); -// AddCommand(make_movable("GetBoxes")); -// AddCommand(make_movable("GetClips")); +// AddCommand(std::make_unique()); +// AddCommand(std::make_unique()); +// AddCommand(std::make_unique()); +// AddCommand(std::make_unique()); +// AddCommand(std::make_unique()); +// AddCommand(std::make_unique("GetAll")); +// AddCommand(std::make_unique("GetCommands")); +// AddCommand(std::make_unique("GetMenus")); +// AddCommand(std::make_unique("GetMenusPlus")); +// AddCommand(std::make_unique("GetBoxes")); +// AddCommand(std::make_unique("GetClips")); -// AddCommand(make_movable()); -// AddCommand(make_movable()); -// AddCommand(make_movable()); -// AddCommand(make_movable()); -// AddCommand(make_movable()); -// AddCommand(make_movable()); -// AddCommand(make_movable()); -// AddCommand(make_movable()); +// AddCommand(std::make_unique()); +// AddCommand(std::make_unique()); +// AddCommand(std::make_unique()); +// AddCommand(std::make_unique()); +// AddCommand(std::make_unique()); +// AddCommand(std::make_unique()); +// AddCommand(std::make_unique()); +// AddCommand(std::make_unique()); } @@ -77,7 +77,7 @@ OldStyleCommandType *CommandDirectory::LookUp(const wxString &cmdName) const return iter->second.get(); } -void CommandDirectory::AddCommand(movable_ptr &&type) +void CommandDirectory::AddCommand(std::unique_ptr &&type) { wxASSERT(type != NULL); // Internal string is shown but only in assertion message diff --git a/src/commands/CommandDirectory.h b/src/commands/CommandDirectory.h index 3dfab92fc..a04af067a 100644 --- a/src/commands/CommandDirectory.h +++ b/src/commands/CommandDirectory.h @@ -44,7 +44,7 @@ public: OldStyleCommandType *LookUp(const wxString &cmdName) const; /// Register a type of command with the directory. - void AddCommand(movable_ptr &&type); + void AddCommand(std::unique_ptr &&type); /// Get a pointer to the singleton instance static CommandDirectory *Get(); diff --git a/src/commands/CommandManager.cpp b/src/commands/CommandManager.cpp index 9c7b52a5a..32220869e 100644 --- a/src/commands/CommandManager.cpp +++ b/src/commands/CommandManager.cpp @@ -566,11 +566,7 @@ std::unique_ptr CommandManager::AddMenuBar(const wxString & sMenu) } auto result = std::make_unique(); -#ifdef __AUDACITY_OLD_STD__ - mMenuBarList.push_back(MenuBarListEntry{sMenu, result.get()}); -#else mMenuBarList.emplace_back(sMenu, result.get()); -#endif return result; } @@ -635,7 +631,7 @@ void CommandManager::EndMenu() wxMenu* CommandManager::BeginSubMenu(const wxString & tName) { mSubMenuList.push_back - (make_movable< SubMenuListEntry > ( tName, std::make_unique() )); + (std::make_unique< SubMenuListEntry > ( tName, std::make_unique() )); mbSeparatorAllowed = false; return mSubMenuList.back()->menu.get(); } @@ -1018,7 +1014,7 @@ CommandListEntry *CommandManager::NewIdentifier(const wxString & nameIn, { // Make a unique_ptr or shared_ptr as appropriate: - auto entry = make_movable(); + auto entry = std::make_unique(); wxString labelPrefix; if (!mSubMenuList.empty()) { diff --git a/src/commands/CommandManager.h b/src/commands/CommandManager.h index 7d75f4f10..ef4b4d78a 100644 --- a/src/commands/CommandManager.h +++ b/src/commands/CommandManager.h @@ -28,9 +28,7 @@ #include "audacity/Types.h" -#ifndef __AUDACITY_OLD_STD__ #include -#endif using CommandParameter = wxString; class TranslatedInternalString; @@ -92,29 +90,14 @@ struct CommandListEntry using MenuBarList = std::vector < MenuBarListEntry >; // to do: remove the extra indirection when Mac compiler moves to newer version -using SubMenuList = std::vector < movable_ptr >; +using SubMenuList = std::vector < std::unique_ptr >; // This is an array of pointers, not structures, because the hash maps also point to them, // so we don't want the structures to relocate with vector operations. -using CommandList = std::vector>; +using CommandList = std::vector>; namespace std { -#ifdef __AUDACITY_OLD_STD__ - namespace tr1 - { - template struct hash; - template<> struct hash< NormalizedKeyString > { - size_t operator () (const NormalizedKeyString &str) const // noexcept - { - auto &stdstr = str.Raw(); // no allocations, a cheap fetch - using Hasher = hash< wxString >; - return Hasher{}( stdstr ); - } - }; - } -#else - // in std, not in tr1. template<> struct hash< NormalizedKeyString > { size_t operator () (const NormalizedKeyString &str) const // noexcept { @@ -123,7 +106,6 @@ namespace std return Hasher{}( stdstr ); } }; -#endif } using CommandKeyHash = std::unordered_map; diff --git a/src/commands/CommandMisc.h b/src/commands/CommandMisc.h index 4f384deb4..822b9f679 100644 --- a/src/commands/CommandMisc.h +++ b/src/commands/CommandMisc.h @@ -29,10 +29,10 @@ typedef std::map ParamBoolMap; // Map from parameter name to a suitable Validator // to do: use hash -typedef std::map> ValidatorMap; +typedef std::map> ValidatorMap; // Map from command name to type // to do: use hash -typedef std::map> CommandMap; +typedef std::map> CommandMap; #endif /* End of include guard: __COMMANDMISC__ */ diff --git a/src/commands/CommandSignature.cpp b/src/commands/CommandSignature.cpp index e0151b557..324cbfad2 100644 --- a/src/commands/CommandSignature.cpp +++ b/src/commands/CommandSignature.cpp @@ -24,7 +24,7 @@ CommandSignature::~CommandSignature() void CommandSignature::AddParameter(const wxString &name, const wxVariant &dft, - movable_ptr &&valid) + std::unique_ptr &&valid) { wxASSERT_MSG(valid->Validate(dft), wxT("Invalid command signature: the default value of '") diff --git a/src/commands/CommandSignature.h b/src/commands/CommandSignature.h index 3f2868615..3d618285a 100644 --- a/src/commands/CommandSignature.h +++ b/src/commands/CommandSignature.h @@ -41,7 +41,7 @@ public: // valid: a suitable validator (caller doesn't need to DELETE it) void AddParameter(const wxString &name, const wxVariant &dft, - movable_ptr &&valid); + std::unique_ptr &&valid); // Methods for accessing the signature ParamValueMap GetDefaults() const; diff --git a/src/commands/CompareAudioCommand.cpp b/src/commands/CompareAudioCommand.cpp index bcd1c45e8..687daaf85 100644 --- a/src/commands/CompareAudioCommand.cpp +++ b/src/commands/CompareAudioCommand.cpp @@ -36,7 +36,7 @@ threshold of difference in two selected tracks #include "CommandContext.h" extern void RegisterCompareAudio( Registrar & R){ - R.AddCommand( make_movable() ); + R.AddCommand( std::make_unique() ); // std::unique_ptr &&target // return std::make_shared(*this, std::move(target)); diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 36deb2ca4..acb2d5fea 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -68,9 +68,7 @@ greater use in future. #include "../Experimental.h" #include "../commands/ScreenshotCommand.h" -#ifndef __AUDACITY_OLD_STD__ #include -#endif static const int kDummyID = 20000; static const int kSaveAsID = 20001; @@ -2127,12 +2125,7 @@ Effect::ModifiedAnalysisTrack::ModifiedAnalysisTrack // So it's okay that we cast it back to const mpOrigTrack = pEffect->mTracks->Replace(const_cast(pOrigTrack), -#ifdef __AUDACITY_OLD_STD__ - std::shared_ptr(newTrack.release()) -#else - std::move(newTrack) -#endif - ); + std::move(newTrack) ); } Effect::ModifiedAnalysisTrack::ModifiedAnalysisTrack(ModifiedAnalysisTrack &&that) diff --git a/src/effects/EffectManager.h b/src/effects/EffectManager.h index b18342f4d..c4b9ac3af 100644 --- a/src/effects/EffectManager.h +++ b/src/effects/EffectManager.h @@ -25,9 +25,7 @@ #include "../PluginManager.h" #include "Effect.h" -#ifndef __AUDACITY_OLD_STD__ #include -#endif class AudacityCommand; class CommandContext; diff --git a/src/effects/NoiseReduction.cpp b/src/effects/NoiseReduction.cpp index 14f8057fa..c250f0b95 100644 --- a/src/effects/NoiseReduction.cpp +++ b/src/effects/NoiseReduction.cpp @@ -343,7 +343,7 @@ private: FloatVector mRealFFTs; FloatVector mImagFFTs; }; - std::vector> mQueue; + std::vector> mQueue; }; /****************************************************************//** @@ -801,7 +801,7 @@ EffectNoiseReduction::Worker::Worker mQueue.resize(mHistoryLen); for (unsigned ii = 0; ii < mHistoryLen; ++ii) - mQueue[ii] = make_movable(mSpectrumSize); + mQueue[ii] = std::make_unique(mSpectrumSize); // Create windows diff --git a/src/effects/SBSMSEffect.cpp b/src/effects/SBSMSEffect.cpp index eb7336d49..6e1c3f895 100644 --- a/src/effects/SBSMSEffect.cpp +++ b/src/effects/SBSMSEffect.cpp @@ -62,8 +62,7 @@ public: std::unique_ptr outputLeftTrack; std::unique_ptr outputRightTrack; - wxFileName failedFileName; - bool error{ false }; + std::exception_ptr mpException {}; }; class SBSMSEffectInterface final : public SBSMSInterfaceSliding { @@ -100,23 +99,16 @@ long resampleCB(void *cb_data, SBSMSFrame *data) // I don't know if we can safely propagate errors through sbsms, and it // does not seem to let us report error codes, so use this roundabout to // stop the effect early. - // This would be easier with std::exception_ptr but we don't have that yet. try { r->leftTrack->Get( (samplePtr)(r->leftBuffer.get()), floatSample, r->offset, blockSize); r->rightTrack->Get( (samplePtr)(r->rightBuffer.get()), floatSample, r->offset, blockSize); } - catch ( const FileException& e ) { - if ( e.cause == FileException::Cause::Read ) - r->failedFileName = e.fileName; - data->size = 0; - r->error = true; - return 0; - } catch ( ... ) { + // Save the exception object for re-throw when out of the library + r->mpException = std::current_exception(); data->size = 0; - r->error = true; return 0; } @@ -425,15 +417,13 @@ bool EffectSBSMS::Process() if (TrackProgress(nWhichTrack, frac)) return false; } - if (rb.failedFileName.IsOk()) - // re-construct an exception - // I wish I had std::exception_ptr instead - // and could re-throw any AudacityException - throw FileException{ - FileException::Cause::Read, rb.failedFileName }; - else if (rb.error) - // well, what? - bGoodResult = false; + + { + auto pException = rb.mpException; + rb.mpException = {}; + if (pException) + std::rethrow_exception(pException); + } if (bGoodResult) { rb.outputLeftTrack->Flush(); diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index 7cec5e9a3..a02a78902 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -1455,7 +1455,7 @@ bool VSTEffect::RealtimeInitialize() bool VSTEffect::RealtimeAddProcessor(unsigned numChannels, float sampleRate) { - mSlaves.push_back(make_movable(mPath, this)); + mSlaves.push_back(std::make_unique(mPath, this)); VSTEffect *const slave = mSlaves.back().get(); slave->SetBlockSize(mBlockSize); diff --git a/src/effects/VST/VSTEffect.h b/src/effects/VST/VSTEffect.h index 072760ba1..e5b055c7b 100644 --- a/src/effects/VST/VSTEffect.h +++ b/src/effects/VST/VSTEffect.h @@ -64,7 +64,7 @@ struct __CFBundle; // /////////////////////////////////////////////////////////////////////////////// -using VSTEffectArray = std::vector < movable_ptr > ; +using VSTEffectArray = std::vector < std::unique_ptr > ; DECLARE_LOCAL_EVENT_TYPE(EVT_SIZEWINDOW, -1); DECLARE_LOCAL_EVENT_TYPE(EVT_UPDATEDISPLAY, -1); diff --git a/src/effects/audiounits/AudioUnitEffect.cpp b/src/effects/audiounits/AudioUnitEffect.cpp index df9bd7be7..212e48c29 100644 --- a/src/effects/audiounits/AudioUnitEffect.cpp +++ b/src/effects/audiounits/AudioUnitEffect.cpp @@ -1346,7 +1346,7 @@ bool AudioUnitEffect::RealtimeInitialize() bool AudioUnitEffect::RealtimeAddProcessor(unsigned numChannels, float sampleRate) { - auto slave = make_movable(mPath, mName, mComponent, this); + auto slave = std::make_unique(mPath, mName, mComponent, this); if (!slave->SetHost(NULL)) return false; diff --git a/src/effects/audiounits/AudioUnitEffect.h b/src/effects/audiounits/AudioUnitEffect.h index 565419864..9576159a9 100644 --- a/src/effects/audiounits/AudioUnitEffect.h +++ b/src/effects/audiounits/AudioUnitEffect.h @@ -34,7 +34,7 @@ class AudioUnitEffect; -using AudioUnitEffectArray = std::vector>; +using AudioUnitEffectArray = std::vector>; class AudioUnitEffectExportDialog; class AudioUnitEffectImportDialog; diff --git a/src/effects/lv2/LV2Effect.h b/src/effects/lv2/LV2Effect.h index 0006641ae..e63d8c37b 100644 --- a/src/effects/lv2/LV2Effect.h +++ b/src/effects/lv2/LV2Effect.h @@ -38,9 +38,7 @@ #include "LoadLV2.h" -#ifndef __AUDACITY_OLD_STD__ #include -#endif #define LV2EFFECTS_VERSION wxT("1.0.0.0") /* i18n-hint: abbreviates @@ -294,7 +292,7 @@ private: bool mUseGUI; - std::vector< movable_ptr_with_deleter > mURIMap; + std::vector< std::unique_ptr > mURIMap; LV2_URI_Map_Feature mUriMapFeature; LV2_URID_Map mURIDMapFeature; @@ -308,7 +306,7 @@ private: LV2_Options_Interface *mOptionsInterface; std::vector mOptions; - std::vector> mFeatures; + std::vector> mFeatures; LV2_Feature *mInstanceAccessFeature; LV2_Feature *mParentFeature; diff --git a/src/effects/lv2/LoadLV2.cpp b/src/effects/lv2/LoadLV2.cpp index de4a1aad0..bb4c0538b 100644 --- a/src/effects/lv2/LoadLV2.cpp +++ b/src/effects/lv2/LoadLV2.cpp @@ -43,9 +43,7 @@ Functions that find and load all LV2 plugins on the system. #include "LoadLV2.h" -#ifndef __AUDACITY_OLD_STD__ #include -#endif // ============================================================================ // Module registration entry point diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index ed522765b..1e3eddb03 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -967,8 +967,7 @@ bool NyquistEffect::TransferDataFromWindow() bool NyquistEffect::ProcessOne() { - mError = false; - mFailedFileName.Clear(); + mpException = {}; nyx_rval rval; @@ -1393,15 +1392,12 @@ bool NyquistEffect::ProcessOne() } // See if GetCallback found read errors - if (mFailedFileName.IsOk()) - // re-construct an exception - // I wish I had std::exception_ptr instead - // and could re-throw any AudacityException - throw FileException{ - FileException::Cause::Read, mFailedFileName }; - else if (mError) - // what, then? - success = false; + { + auto pException = mpException; + mpException = {}; + if (pException) + std::rethrow_exception( pException ); + } if (!success) return false; @@ -2156,14 +2152,9 @@ int NyquistEffect::GetCallback(float *buffer, int ch, mCurBuffer[ch].ptr(), floatSample, mCurBufferStart[ch], mCurBufferLen[ch]); } - catch ( const FileException& e ) { - if ( e.cause == FileException::Cause::Read ) - mFailedFileName = e.fileName; - mError = true; - return -1; - } catch ( ... ) { - mError = true; + // Save the exception object for re-throw when out of the library + mpException = std::current_exception(); return -1; } } diff --git a/src/effects/nyquist/Nyquist.h b/src/effects/nyquist/Nyquist.h index da215f033..beaefe97a 100644 --- a/src/effects/nyquist/Nyquist.h +++ b/src/effects/nyquist/Nyquist.h @@ -275,8 +275,7 @@ private: wxTextCtrl *mCommandText; wxCheckBox *mVersionCheckBox; - bool mError{ false }; - wxFileName mFailedFileName; + std::exception_ptr mpException {}; DECLARE_EVENT_TABLE() diff --git a/src/effects/vamp/VampEffect.cpp b/src/effects/vamp/VampEffect.cpp index c6273859b..6b87178b2 100644 --- a/src/effects/vamp/VampEffect.cpp +++ b/src/effects/vamp/VampEffect.cpp @@ -43,10 +43,6 @@ #include "../../LabelTrack.h" #include "../../WaveTrack.h" -#ifdef __AUDACITY_OLD_STD__ -#include -#endif - enum { ID_Program = 10000, diff --git a/src/export/Export.cpp b/src/export/Export.cpp index a6c470118..e8adf3d75 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -325,7 +325,7 @@ int Exporter::FindFormatIndex(int exportindex) return 0; } -void Exporter::RegisterPlugin(movable_ptr &&ExportPlugin) +void Exporter::RegisterPlugin(std::unique_ptr &&ExportPlugin) { mPlugins.push_back(std::move(ExportPlugin)); } diff --git a/src/export/Export.h b/src/export/Export.h index 75babd9c4..7b67a7225 100644 --- a/src/export/Export.h +++ b/src/export/Export.h @@ -146,7 +146,7 @@ private: std::vector mFormatInfos; }; -using ExportPluginArray = std::vector < movable_ptr< ExportPlugin > > ; +using ExportPluginArray = std::vector < std::unique_ptr< ExportPlugin > > ; WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxWindow *, WindowPtrArray, class AUDACITY_DLL_API); //---------------------------------------------------------------------------- @@ -161,7 +161,7 @@ public: void SetFileDialogTitle( const wxString & DialogTitle ); void SetDefaultFormat( const wxString & Format ){ mFormatName = Format;}; - void RegisterPlugin(movable_ptr &&plugin); + void RegisterPlugin(std::unique_ptr &&plugin); bool Process(AudacityProject *project, bool selectedOnly, double t0, double t1); diff --git a/src/export/ExportCL.cpp b/src/export/ExportCL.cpp index 7a331d7d5..a5a1777cd 100644 --- a/src/export/ExportCL.cpp +++ b/src/export/ExportCL.cpp @@ -545,8 +545,8 @@ wxWindow *ExportCL::OptionsCreate(wxWindow *parent, int format) return safenew ExportCLOptions(parent, format); } -movable_ptr New_ExportCL() +std::unique_ptr New_ExportCL() { - return make_movable(); + return std::make_unique(); } diff --git a/src/export/ExportCL.h b/src/export/ExportCL.h index 5520e9479..4a4033650 100644 --- a/src/export/ExportCL.h +++ b/src/export/ExportCL.h @@ -19,6 +19,6 @@ class ExportPlugin; * factory method New_ExportCL() which creates a NEW ExportCL object and * returns a pointer to it. The rest of the class declaration is in ExportCL.cpp */ -movable_ptr New_ExportCL(); +std::unique_ptr New_ExportCL(); #endif diff --git a/src/export/ExportFFmpeg.cpp b/src/export/ExportFFmpeg.cpp index 4ecd6fd42..d1b1a0906 100644 --- a/src/export/ExportFFmpeg.cpp +++ b/src/export/ExportFFmpeg.cpp @@ -1095,9 +1095,9 @@ wxWindow *ExportFFmpeg::OptionsCreate(wxWindow *parent, int format) return ExportPlugin::OptionsCreate(parent, format); } -movable_ptr New_ExportFFmpeg() +std::unique_ptr New_ExportFFmpeg() { - return make_movable(); + return std::make_unique(); } #endif diff --git a/src/export/ExportFFmpeg.h b/src/export/ExportFFmpeg.h index 7f5ba312b..85a0ed26c 100644 --- a/src/export/ExportFFmpeg.h +++ b/src/export/ExportFFmpeg.h @@ -18,6 +18,6 @@ class ExportPlugin; * factory method New_ExportFFmpeg() which creates a NEW ExportFFmpeg object and * returns a pointer to it. The rest of the class declaration is in ExportFFmpeg.cpp */ -movable_ptr New_ExportFFmpeg(); +std::unique_ptr New_ExportFFmpeg(); #endif diff --git a/src/export/ExportFFmpegDialogs.h b/src/export/ExportFFmpegDialogs.h index dc67f870f..b2f4afe20 100644 --- a/src/export/ExportFFmpegDialogs.h +++ b/src/export/ExportFFmpegDialogs.h @@ -22,9 +22,7 @@ LRN #include "../FileNames.h" #include "../widgets/wxPanelWrapper.h" -#ifndef __AUDACITY_OLD_STD__ #include -#endif /// Identifiers for pre-set export types. diff --git a/src/export/ExportFLAC.cpp b/src/export/ExportFLAC.cpp index 86cecab75..25ff8b031 100644 --- a/src/export/ExportFLAC.cpp +++ b/src/export/ExportFLAC.cpp @@ -450,9 +450,9 @@ bool ExportFLAC::GetMetadata(AudacityProject *project, const Tags *tags) return true; } -movable_ptr New_ExportFLAC() +std::unique_ptr New_ExportFLAC() { - return make_movable(); + return std::make_unique(); } #endif // USE_LIBFLAC diff --git a/src/export/ExportFLAC.h b/src/export/ExportFLAC.h index 11cff27b7..f22e48296 100644 --- a/src/export/ExportFLAC.h +++ b/src/export/ExportFLAC.h @@ -18,7 +18,7 @@ class ExportPlugin; * factory method New_ExportFLAC() which creates a NEW ExportFLAC object and * returns a pointer to it. The rest of the class declaration is in ExportFLAC.cpp */ -movable_ptr New_ExportFLAC(); +std::unique_ptr New_ExportFLAC(); #endif diff --git a/src/export/ExportMP2.cpp b/src/export/ExportMP2.cpp index b18cd3f24..e6889f775 100644 --- a/src/export/ExportMP2.cpp +++ b/src/export/ExportMP2.cpp @@ -464,9 +464,9 @@ void ExportMP2::AddFrame(struct id3_tag *tp, const wxString & n, const wxString } #endif -movable_ptr New_ExportMP2() +std::unique_ptr New_ExportMP2() { - return make_movable(); + return std::make_unique(); } #endif // #ifdef USE_LIBTWOLAME diff --git a/src/export/ExportMP2.h b/src/export/ExportMP2.h index cf21a73e9..19593abfa 100644 --- a/src/export/ExportMP2.h +++ b/src/export/ExportMP2.h @@ -19,7 +19,7 @@ class ExportPlugin; * factory method New_ExportMP2() which creates a NEW ExportMP2 object and * returns a pointer to it. The rest of the class declaration is in ExportMP2.cpp */ -movable_ptr New_ExportMP2(); +std::unique_ptr New_ExportMP2(); #endif diff --git a/src/export/ExportMP3.cpp b/src/export/ExportMP3.cpp index f23b95ca5..0a28c794e 100644 --- a/src/export/ExportMP3.cpp +++ b/src/export/ExportMP3.cpp @@ -2158,9 +2158,9 @@ void ExportMP3::AddFrame(struct id3_tag *tp, const wxString & n, const wxString } #endif -movable_ptr New_ExportMP3() +std::unique_ptr New_ExportMP3() { - return make_movable(); + return std::make_unique(); } //---------------------------------------------------------------------------- diff --git a/src/export/ExportMP3.h b/src/export/ExportMP3.h index 6cbb576bc..f7bba5e22 100644 --- a/src/export/ExportMP3.h +++ b/src/export/ExportMP3.h @@ -20,7 +20,7 @@ class wxWindow; /** Factory method New_ExportMP3() which creates a NEW ExportMP3 object and * returns a pointer to it. The rest of the class declaration is in ExportMP3.cpp */ -movable_ptr New_ExportMP3(); +std::unique_ptr New_ExportMP3(); //---------------------------------------------------------------------------- // Get MP3 library versioqn diff --git a/src/export/ExportOGG.cpp b/src/export/ExportOGG.cpp index 3ab2ab3d2..1dd1712d5 100644 --- a/src/export/ExportOGG.cpp +++ b/src/export/ExportOGG.cpp @@ -400,9 +400,9 @@ bool ExportOGG::FillComment(AudacityProject *project, vorbis_comment *comment, c return true; } -movable_ptr New_ExportOGG() +std::unique_ptr New_ExportOGG() { - return make_movable(); + return std::make_unique(); } #endif // USE_LIBVORBIS diff --git a/src/export/ExportOGG.h b/src/export/ExportOGG.h index 6c18d3961..160d081e0 100644 --- a/src/export/ExportOGG.h +++ b/src/export/ExportOGG.h @@ -18,7 +18,7 @@ class ExportPlugin; * factory method New_ExportOGG() which creates a NEW ExportOGG object and * returns a pointer to it. The rest of the class declaration is in ExportOGG.cpp */ -movable_ptr New_ExportOGG(); +std::unique_ptr New_ExportOGG(); #endif diff --git a/src/export/ExportPCM.cpp b/src/export/ExportPCM.cpp index e4fd3bb1e..7bcf40359 100644 --- a/src/export/ExportPCM.cpp +++ b/src/export/ExportPCM.cpp @@ -909,7 +909,7 @@ bool ExportPCM::CheckFileName(wxFileName &filename, int format) return ExportPlugin::CheckFileName(filename, format); } -movable_ptr New_ExportPCM() +std::unique_ptr New_ExportPCM() { - return make_movable(); + return std::make_unique(); } diff --git a/src/export/ExportPCM.h b/src/export/ExportPCM.h index 96dda834c..6fc957de7 100644 --- a/src/export/ExportPCM.h +++ b/src/export/ExportPCM.h @@ -18,7 +18,7 @@ class ExportPlugin; * factory method New_ExportPCM() which creates a NEW ExportPCM object and * returns a pointer to it. The rest of the class declaration is in ExportPCM.cpp */ -movable_ptr New_ExportPCM(); +std::unique_ptr New_ExportPCM(); #endif diff --git a/src/import/Import.cpp b/src/import/Import.cpp index 63cc0eaf1..53ad404a0 100644 --- a/src/import/Import.cpp +++ b/src/import/Import.cpp @@ -124,13 +124,8 @@ void Importer::GetSupportedImportFormats(FormatList *formatList) { for(const auto &importPlugin : mImportPluginList) { -#ifdef __AUDACITY_OLD_STD__ - formatList->push_back(Format{importPlugin->GetPluginFormatDescription(), - importPlugin->GetSupportedExtensions()}); -#else formatList->emplace_back(importPlugin->GetPluginFormatDescription(), importPlugin->GetSupportedExtensions()); -#endif } } @@ -167,7 +162,7 @@ void Importer::ReadImportItems() if (toker.CountTokens() != 2) break; - auto new_item = make_movable(); + auto new_item = std::make_unique(); /* First token is the filtering condition, second - the filter list */ condition = toker.GetNextToken(); @@ -312,9 +307,9 @@ void Importer::WriteImportItems() } while( true ); } -movable_ptr Importer::CreateDefaultImportItem() +std::unique_ptr Importer::CreateDefaultImportItem() { - auto new_item = make_movable(); + auto new_item = std::make_unique(); new_item->extensions.Add(wxT("*")); new_item->mime_types.Add(wxT("*")); diff --git a/src/import/Import.h b/src/import/Import.h index 035b2ad4a..d380610de 100644 --- a/src/import/Import.h +++ b/src/import/Import.h @@ -44,7 +44,7 @@ public: class ExtImportItem; using FormatList = std::vector ; -using ExtImportItems = std::vector< movable_ptr >; +using ExtImportItems = std::vector< std::unique_ptr >; class ExtImportItem { @@ -134,7 +134,7 @@ public: * Allocates NEW ExtImportItem, fills it with default data * and returns a pointer to it. */ - movable_ptr CreateDefaultImportItem(); + std::unique_ptr CreateDefaultImportItem(); static bool IsMidi(const wxString &fName); diff --git a/src/import/ImportFFmpeg.cpp b/src/import/ImportFFmpeg.cpp index 132d9a8bd..c3257e124 100644 --- a/src/import/ImportFFmpeg.cpp +++ b/src/import/ImportFFmpeg.cpp @@ -285,7 +285,7 @@ private: void GetFFmpegImportPlugin(ImportPluginList &importPluginList, UnusableImportPluginList &WXUNUSED(unusableImportPluginList)) { - importPluginList.push_back( make_movable() ); + importPluginList.push_back( std::make_unique() ); } @@ -584,13 +584,13 @@ ProgressResult FFmpegImportFileHandle::Import(TrackFactory *trackFactory, //at this point we know the file is good and that we have to load the number of channels in mScs[s]->m_stream->codec->channels; //so for OD loading we create the tracks and releasee the modal lock after starting the ODTask. if (mUsingOD) { - std::vector> tasks; + std::vector> tasks; //append blockfiles to each stream and add an individual ODDecodeTask for each one. s = -1; for (const auto &stream : mChannels) { ++s; auto odTask = - make_movable(mScs, ODDecodeFFmpegTask::FromList(mChannels), mContext, s); + std::make_unique(mScs, ODDecodeFFmpegTask::FromList(mChannels), mContext, s); odTask->CreateFileDecoder(mFilename); //each stream has different duration. We need to know it if seeking is to be allowed. diff --git a/src/import/ImportFLAC.cpp b/src/import/ImportFLAC.cpp index 7a5a3043f..db92be087 100644 --- a/src/import/ImportFLAC.cpp +++ b/src/import/ImportFLAC.cpp @@ -62,7 +62,7 @@ void GetFLACImportPlugin(ImportPluginList &importPluginList, UnusableImportPluginList &unusableImportPluginList) { unusableImportPluginList.push_back( - make_movable + std::make_unique (DESC, wxArrayString(WXSIZEOF(exts), exts)) ); } @@ -182,7 +182,7 @@ private: bool mStreamInfoDone; ProgressResult mUpdateResult; TrackHolders mChannels; - movable_ptr mDecoderTask; + std::unique_ptr mDecoderTask; }; @@ -293,7 +293,7 @@ FLAC__StreamDecoderWriteStatus MyFLACFile::write_callback(const FLAC__Frame *fra void GetFLACImportPlugin(ImportPluginList &importPluginList, UnusableImportPluginList &WXUNUSED(unusableImportPluginList)) { - importPluginList.push_back( make_movable() ); + importPluginList.push_back( std::make_unique() ); } @@ -358,7 +358,7 @@ FLACImportFileHandle::FLACImportFileHandle(const wxString & name) bool FLACImportFileHandle::Init() { #ifdef EXPERIMENTAL_OD_FLAC - mDecoderTask = make_movable(); + mDecoderTask = std::make_unique(); ODFlacDecoder* odDecoder = (ODFlacDecoder*)mDecoderTask->CreateFileDecoder(mFilename); if(!odDecoder || !odDecoder->ReadHeader()) @@ -522,7 +522,7 @@ ProgressResult FLACImportFileHandle::Import(TrackFactory *trackFactory, { //if we have 3 more channels, they get imported on seperate tracks, so we add individual tasks for each. ODManager::Instance()->AddNewTask(std::move(mDecoderTask)); - mDecoderTask = make_movable(); //TODO: see if we need to use clone to keep the metadata. + mDecoderTask = std::make_unique(); //TODO: see if we need to use clone to keep the metadata. } } //if we have mono or a linked track (stereo), we add ONE task for the one linked wave track diff --git a/src/import/ImportForwards.h b/src/import/ImportForwards.h index f05256761..d41ccc0ec 100644 --- a/src/import/ImportForwards.h +++ b/src/import/ImportForwards.h @@ -16,8 +16,8 @@ class ImportPlugin; class UnusableImportPlugin; using ImportPluginList = - std::vector< movable_ptr >; + std::vector< std::unique_ptr >; using UnusableImportPluginList = - std::vector< movable_ptr >; + std::vector< std::unique_ptr >; #endif diff --git a/src/import/ImportGStreamer.cpp b/src/import/ImportGStreamer.cpp index 0075b44bc..e3dd8f6c6 100644 --- a/src/import/ImportGStreamer.cpp +++ b/src/import/ImportGStreamer.cpp @@ -232,7 +232,7 @@ private: bool mAsyncDone; //!< true = 1st async-done message received GMutex mStreamsLock; //!< Mutex protecting the mStreams array - std::vector> mStreams; //!< Array of pointers to stream contexts + std::vector> mStreams; //!< Array of pointers to stream contexts }; /// A representative of GStreamer loader in @@ -299,7 +299,7 @@ GetGStreamerImportPlugin(ImportPluginList &importPluginList, nano); // Instantiate plugin - auto plug = make_movable(); + auto plug = std::make_unique(); // No supported extensions...no gstreamer plugins installed if (plug->GetSupportedExtensions().GetCount() == 0) @@ -569,7 +569,7 @@ GStreamerImportFileHandle::OnPadAdded(GstPad *pad) { // Allocate a NEW stream context - auto uc = make_movable(); + auto uc = std::make_unique(); c = uc.get(); if (!c) { diff --git a/src/import/ImportLOF.cpp b/src/import/ImportLOF.cpp index 96cc4e56c..73cf6e205 100644 --- a/src/import/ImportLOF.cpp +++ b/src/import/ImportLOF.cpp @@ -171,7 +171,7 @@ LOFImportFileHandle::LOFImportFileHandle void GetLOFImportPlugin(ImportPluginList &importPluginList, UnusableImportPluginList & WXUNUSED(unusableImportPluginList)) { - importPluginList.push_back( make_movable() ); + importPluginList.push_back( std::make_unique() ); } wxString LOFImportPlugin::GetPluginFormatDescription() diff --git a/src/import/ImportMP3.cpp b/src/import/ImportMP3.cpp index f4c42b0a5..7726a9a1e 100644 --- a/src/import/ImportMP3.cpp +++ b/src/import/ImportMP3.cpp @@ -62,7 +62,7 @@ void GetMP3ImportPlugin(ImportPluginList &importPluginList, UnusableImportPluginList &unusableImportPluginList) { unusableImportPluginList.push_back( - make_movable + std::make_unique (DESC, wxArrayString(WXSIZEOF(exts), exts)) ); } @@ -159,7 +159,7 @@ private: void GetMP3ImportPlugin(ImportPluginList &importPluginList, UnusableImportPluginList & WXUNUSED(unusableImportPluginList)) { - importPluginList.push_back( make_movable() ); + importPluginList.push_back( std::make_unique() ); } /* The MAD callbacks */ diff --git a/src/import/ImportOGG.cpp b/src/import/ImportOGG.cpp index c0065250b..f2a7b9179 100644 --- a/src/import/ImportOGG.cpp +++ b/src/import/ImportOGG.cpp @@ -60,7 +60,7 @@ void GetOGGImportPlugin(ImportPluginList &importPluginList, UnusableImportPluginList &unusableImportPluginList) { unusableImportPluginList.push_back( - make_movable + std::make_unique (DESC, wxArrayString(WXSIZEOF(exts), exts)) ); } @@ -163,7 +163,7 @@ private: void GetOGGImportPlugin(ImportPluginList &importPluginList, UnusableImportPluginList & WXUNUSED(unusableImportPluginList)) { - importPluginList.push_back( make_movable() ); + importPluginList.push_back( std::make_unique() ); } wxString OggImportPlugin::GetPluginFormatDescription() diff --git a/src/import/ImportPCM.cpp b/src/import/ImportPCM.cpp index 82e861399..19762b6de 100644 --- a/src/import/ImportPCM.cpp +++ b/src/import/ImportPCM.cpp @@ -117,7 +117,7 @@ private: void GetPCMImportPlugin(ImportPluginList & importPluginList, UnusableImportPluginList & WXUNUSED(unusableImportPluginList)) { - importPluginList.push_back( make_movable() ); + importPluginList.push_back( std::make_unique() ); } wxString PCMImportPlugin::GetPluginFormatDescription() @@ -436,7 +436,7 @@ ProgressResult PCMImportFileHandle::Import(TrackFactory *trackFactory, if(useOD) { - auto computeTask = make_movable(); + auto computeTask = std::make_unique(); bool moreThanStereo = mInfo.channels>2; for (const auto &channel : channels) { @@ -445,7 +445,7 @@ ProgressResult PCMImportFileHandle::Import(TrackFactory *trackFactory, { //if we have 3 more channels, they get imported on seperate tracks, so we add individual tasks for each. ODManager::Instance()->AddNewTask(std::move(computeTask)); - computeTask = make_movable(); + computeTask = std::make_unique(); } } //if we have a linked track, we add ONE task. diff --git a/src/import/ImportQT.cpp b/src/import/ImportQT.cpp index a0781966b..badc5a193 100644 --- a/src/import/ImportQT.cpp +++ b/src/import/ImportQT.cpp @@ -41,7 +41,7 @@ void GetQTImportPlugin(ImportPluginList &importPluginList, UnusableImportPluginList &unusableImportPluginList) { unusableImportPluginList.push_back( - make_movable + std::make_unique (DESC, wxArrayString(WXSIZEOF(exts), exts)) ); } @@ -173,7 +173,7 @@ class QTImportFileHandle final : public ImportFileHandle void GetQTImportPlugin(ImportPluginList &importPluginList, UnusableImportPluginList &unusableImportPluginList) { - importPluginList.push_back( make_movable() ); + importPluginList.push_back( std::make_unique() ); } wxString QTImportPlugin::GetPluginFormatDescription() diff --git a/src/import/ImportRaw.h b/src/import/ImportRaw.h index 8693dfdd5..a42375e49 100644 --- a/src/import/ImportRaw.h +++ b/src/import/ImportRaw.h @@ -21,28 +21,8 @@ class wxWindow; #include -#ifdef __AUDACITY_OLD_STD__ - -class TrackHolder : public std::shared_ptr < WaveTrack > -{ -public: - // shared_ptr can construct from unique_ptr&& in newer std, but not older, - // so define it here - TrackHolder &operator=(std::unique_ptr &&that) - { - reset(that.release()); - return *this; - } -}; - -using TrackHolders = std::vector; - -#else - using TrackHolders = std::vector>; -#endif - void ImportRaw(wxWindow *parent, const wxString &fileName, TrackFactory *trackFactory, TrackHolders &outTracks); diff --git a/src/ondemand/ODComputeSummaryTask.cpp b/src/ondemand/ODComputeSummaryTask.cpp index 28910c0c2..a22bebf57 100644 --- a/src/ondemand/ODComputeSummaryTask.cpp +++ b/src/ondemand/ODComputeSummaryTask.cpp @@ -35,9 +35,9 @@ ODComputeSummaryTask::ODComputeSummaryTask() mHasUpdateRan=false; } -movable_ptr ODComputeSummaryTask::Clone() const +std::unique_ptr ODComputeSummaryTask::Clone() const { - auto clone = make_movable(); + auto clone = std::make_unique(); clone->mDemandSample = GetDemandSample(); // This std::move is needed to "upcast" the pointer type return std::move(clone); diff --git a/src/ondemand/ODComputeSummaryTask.h b/src/ondemand/ODComputeSummaryTask.h index 3f767535d..673e3c4f2 100644 --- a/src/ondemand/ODComputeSummaryTask.h +++ b/src/ondemand/ODComputeSummaryTask.h @@ -36,7 +36,7 @@ class ODComputeSummaryTask final : public ODTask ODComputeSummaryTask(); virtual ~ODComputeSummaryTask(){}; - movable_ptr Clone() const override; + std::unique_ptr Clone() const override; ///Subclasses should override to return respective type. unsigned int GetODType() override { return eODPCMSummary; } diff --git a/src/ondemand/ODDecodeFFmpegTask.cpp b/src/ondemand/ODDecodeFFmpegTask.cpp index d180d5182..e291e5dce 100644 --- a/src/ondemand/ODDecodeFFmpegTask.cpp +++ b/src/ondemand/ODDecodeFFmpegTask.cpp @@ -82,7 +82,7 @@ public: bool SeekingAllowed() ; private: - void InsertCache(movable_ptr &&cache); + void InsertCache(std::unique_ptr &&cache); //puts the actual audio samples into the blockfile's data array int FillDataFromCache(samplePtr & data, sampleFormat outFormat, sampleCount & start, size_t& len, unsigned int channel); @@ -100,7 +100,7 @@ private: ScsPtr mScs; //!< Pointer to array of pointers to stream contexts. ODDecodeFFmpegTask::Streams mChannels; std::shared_ptr mContext; //!< Format description, also contains metadata and some useful info - std::vector> mDecodeCache; + std::vector> mDecodeCache; int mNumSamplesInCache; sampleCount mCurrentPos; //the index of the next sample to be decoded size_t mCurrentLen; //length of the last packet decoded @@ -140,9 +140,9 @@ ODDecodeFFmpegTask::~ODDecodeFFmpegTask() } -movable_ptr ODDecodeFFmpegTask::Clone() const +std::unique_ptr ODDecodeFFmpegTask::Clone() const { - auto clone = make_movable(mScs, Streams{ mChannels }, mContext, mStreamIndex); + auto clone = std::make_unique(mScs, Streams{ mChannels }, mContext, mStreamIndex); clone->mDemandSample=GetDemandSample(); //the decoders and blockfiles should not be copied. They are created as the task runs. @@ -157,7 +157,7 @@ ODFileDecoder* ODDecodeFFmpegTask::CreateFileDecoder(const wxString & fileName) { // Open the file for import auto decoder = - make_movable(fileName, mScs, ODDecodeFFmpegTask::Streams{ mChannels }, + std::make_unique(fileName, mScs, ODDecodeFFmpegTask::Streams{ mChannels }, mContext, mStreamIndex); mDecoders.push_back(std::move(decoder)); @@ -394,7 +394,7 @@ int ODFFmpegDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCo // Is there a proof size_t will not overflow size_t? // Result is surely nonnegative. auto amt = (actualDecodeStart - start).as_size_t(); - auto cache = make_movable(); + auto cache = std::make_unique(); //wxPrintf("skipping/zeroing %i samples. - now:%llu (%f), last:%llu, lastlen:%lu, start %llu, len %lu\n",amt,actualDecodeStart, actualDecodeStartdouble, mCurrentPos, mCurrentLen, start, len); @@ -607,7 +607,7 @@ int ODFFmpegDecoder::DecodeFrame(streamContext *sc, bool flushing) //TODO- consider growing/unioning a few cache buffers like WaveCache does. //however we can't use wavecache as it isn't going to handle our stereo interleaved part, and isn't for samples //However if other ODDecode tasks need this, we should do a NEW class for caching. - auto cache = make_movable(); + auto cache = std::make_unique(); //len is number of samples per channel // wxASSERT(sc->m_stream->codec->channels > 0); cache->numChannels = std::max(0, sc->m_stream->codec->channels); @@ -623,7 +623,7 @@ int ODFFmpegDecoder::DecodeFrame(streamContext *sc, bool flushing) return ret; } -void ODFFmpegDecoder::InsertCache(movable_ptr &&cache) { +void ODFFmpegDecoder::InsertCache(std::unique_ptr &&cache) { int searchStart = 0; int searchEnd = mDecodeCache.size(); //size() is also a valid insert index. int guess = 0; diff --git a/src/ondemand/ODDecodeFFmpegTask.h b/src/ondemand/ODDecodeFFmpegTask.h index ca4151cdd..404e0b58b 100644 --- a/src/ondemand/ODDecodeFFmpegTask.h +++ b/src/ondemand/ODDecodeFFmpegTask.h @@ -37,7 +37,7 @@ public: ODDecodeFFmpegTask(const ScsPtr &scs, Streams &&channels, const std::shared_ptr &context, int streamIndex); virtual ~ODDecodeFFmpegTask(); - movable_ptr Clone() const override; + std::unique_ptr Clone() const override; ///Creates an ODFileDecoder that decodes a file of filetype the subclass handles. ODFileDecoder* CreateFileDecoder(const wxString & fileName) override; diff --git a/src/ondemand/ODDecodeFlacTask.cpp b/src/ondemand/ODDecodeFlacTask.cpp index 2145f3fbe..9752f687b 100644 --- a/src/ondemand/ODDecodeFlacTask.cpp +++ b/src/ondemand/ODDecodeFlacTask.cpp @@ -33,9 +33,9 @@ ODDecodeFlacTask::~ODDecodeFlacTask() } -movable_ptr ODDecodeFlacTask::Clone() const +std::unique_ptr ODDecodeFlacTask::Clone() const { - auto clone = make_movable(); + auto clone = std::make_unique(); clone->mDemandSample = GetDemandSample(); //the decoders and blockfiles should not be copied. They are created as the task runs. @@ -304,7 +304,7 @@ ODFileDecoder* ODDecodeFlacTask::CreateFileDecoder(const wxString & fileName) } // Open the file for import - auto decoder = std::make_movable(fileName); + auto decoder = std::std::make_unique(fileName); */ /* bool success = decoder->Init(); @@ -313,7 +313,7 @@ ODFileDecoder* ODDecodeFlacTask::CreateFileDecoder(const wxString & fileName) } */ // Open the file for import - auto decoder = make_movable(fileName); + auto decoder = std::make_unique(fileName); mDecoders.push_back(std::move(decoder)); return mDecoders.back().get(); diff --git a/src/ondemand/ODDecodeFlacTask.h b/src/ondemand/ODDecodeFlacTask.h index 4893860e3..3293bfe48 100644 --- a/src/ondemand/ODDecodeFlacTask.h +++ b/src/ondemand/ODDecodeFlacTask.h @@ -51,7 +51,7 @@ class ODDecodeFlacTask final : public ODDecodeTask virtual ~ODDecodeFlacTask(); - movable_ptr Clone() const override; + std::unique_ptr Clone() const override; ///Creates an ODFileDecoder that decodes a file of filetype the subclass handles. ODFileDecoder* CreateFileDecoder(const wxString & fileName) override; diff --git a/src/ondemand/ODDecodeTask.h b/src/ondemand/ODDecodeTask.h index 0c8d2eef4..136fbf796 100644 --- a/src/ondemand/ODDecodeTask.h +++ b/src/ondemand/ODDecodeTask.h @@ -90,7 +90,7 @@ protected: std::vector> mBlockFiles; - std::vector> mDecoders; + std::vector> mDecoders; int mMaxBlockFiles; diff --git a/src/ondemand/ODManager.cpp b/src/ondemand/ODManager.cpp index 0f39a8b47..494919249 100644 --- a/src/ondemand/ODManager.cpp +++ b/src/ondemand/ODManager.cpp @@ -142,7 +142,7 @@ void ODManager::RemoveTaskIfInQueue(ODTask* task) /// ///@param task the task to add ///@param lockMutex locks the mutexes if true (default). This function is used within other ODManager calls, which many need to set this to false. -void ODManager::AddNewTask(movable_ptr &&mtask, bool lockMutex) +void ODManager::AddNewTask(std::unique_ptr &&mtask, bool lockMutex) { auto task = mtask.get(); ODWaveTrackTaskQueue* queue = NULL; @@ -168,7 +168,7 @@ void ODManager::AddNewTask(movable_ptr &&mtask, bool lockMutex) { //Make a NEW one, add it to the local track queue, and to the immediate running task list, //since this task is definitely at the head - auto newqueue = make_movable(); + auto newqueue = std::make_unique(); newqueue->AddTask(std::move(mtask)); mQueues.push_back(std::move(newqueue)); if(lockMutex) diff --git a/src/ondemand/ODManager.h b/src/ondemand/ODManager.h index 77ff7b7c2..b173f4907 100644 --- a/src/ondemand/ODManager.h +++ b/src/ondemand/ODManager.h @@ -62,7 +62,7 @@ class ODManager final void DecrementCurrentThreads(); ///Adds a wavetrack, creates a queue member. - void AddNewTask(movable_ptr &&mtask, bool lockMutex=true); + void AddNewTask(std::unique_ptr &&mtask, bool lockMutex=true); ///Wakes the queue loop up by signalling its condition variable. void SignalTaskQueueLoop(); @@ -140,7 +140,7 @@ class ODManager final static std::unique_ptr pMan; //List of tracks and their active and inactive tasks. - std::vector> mQueues; + std::vector> mQueues; ODLock mQueuesMutex; //List of current Task to do. diff --git a/src/ondemand/ODTask.h b/src/ondemand/ODTask.h index c8736120d..5de0d0dd1 100644 --- a/src/ondemand/ODTask.h +++ b/src/ondemand/ODTask.h @@ -55,7 +55,7 @@ class ODTask /* not final */ virtual ~ODTask(){}; //clones everything except information about the tracks. - virtual movable_ptr Clone() const = 0; + virtual std::unique_ptr Clone() const = 0; ///Subclasses should override to return respective type. virtual unsigned int GetODType(){return eODNone;} diff --git a/src/ondemand/ODWaveTrackTaskQueue.cpp b/src/ondemand/ODWaveTrackTaskQueue.cpp index 602794283..73e6bc9bf 100644 --- a/src/ondemand/ODWaveTrackTaskQueue.cpp +++ b/src/ondemand/ODWaveTrackTaskQueue.cpp @@ -101,7 +101,7 @@ void ODWaveTrackTaskQueue::AddWaveTrack(WaveTrack* track) mTracksMutex.Unlock(); } -void ODWaveTrackTaskQueue::AddTask(movable_ptr &&mtask) +void ODWaveTrackTaskQueue::AddTask(std::unique_ptr &&mtask) { ODTask *task = mtask.get(); diff --git a/src/ondemand/ODWaveTrackTaskQueue.h b/src/ondemand/ODWaveTrackTaskQueue.h index 368a0ba64..31ae9544f 100644 --- a/src/ondemand/ODWaveTrackTaskQueue.h +++ b/src/ondemand/ODWaveTrackTaskQueue.h @@ -72,7 +72,7 @@ class ODWaveTrackTaskQueue final int GetNumWaveTracks(); ///Add a task to the queue. - void AddTask(movable_ptr &&mtask); + void AddTask(std::unique_ptr &&mtask); //returns true if either tracks or tasks are empty bool IsEmpty(); @@ -106,7 +106,7 @@ class ODWaveTrackTaskQueue final ODLock mTracksMutex; ///the list of tasks associated with the tracks. This class owns these tasks. - std::vector> mTasks; + std::vector> mTasks; ODLock mTasksMutex; }; diff --git a/src/widgets/ExpandingToolBar.cpp b/src/widgets/ExpandingToolBar.cpp index 6c81652b4..425cef174 100644 --- a/src/widgets/ExpandingToolBar.cpp +++ b/src/widgets/ExpandingToolBar.cpp @@ -312,7 +312,7 @@ protected: void ExpandingToolBar::RecursivelyPushEventHandlers(wxWindow *win) { if (!mWindowHash[win]) { - mHandlers.push_back(make_movable + mHandlers.push_back(std::make_unique (this, win, win->GetEventHandler())); mWindowHash[win] = 1; } diff --git a/src/widgets/ExpandingToolBar.h b/src/widgets/ExpandingToolBar.h index b107ecb5d..7cfcffc64 100644 --- a/src/widgets/ExpandingToolBar.h +++ b/src/widgets/ExpandingToolBar.h @@ -23,9 +23,7 @@ #include "ImageRoll.h" #include "wxPanelWrapper.h" -#ifndef __AUDACITY_OLD_STD__ #include -#endif class wxDragImage; @@ -125,7 +123,7 @@ class ExpandingToolBar final : public wxPanelWrapper DECLARE_EVENT_TABLE() friend class ExpandingToolBarEvtHandler; - std::vector< movable_ptr< ExpandingToolBarEvtHandler > > mHandlers; + std::vector< std::unique_ptr< ExpandingToolBarEvtHandler > > mHandlers; }; class ToolBarGrabber final : public wxPanelWrapper diff --git a/src/widgets/Grid.h b/src/widgets/Grid.h index 173796e4b..06bee3552 100644 --- a/src/widgets/Grid.h +++ b/src/widgets/Grid.h @@ -226,7 +226,7 @@ class Grid final : public wxGrid #if wxUSE_ACCESSIBILITY GridAx *mAx; - std::vector> mChildren; + std::vector> mChildren; int mObjNdx; #endif