Replace most inclusions of MemoryX.h with <memory> ...

... Most often it was needed for a custom definition of std::make_unique, but
we build C++14 now.
This commit is contained in:
Paul Licameli 2021-05-21 14:13:13 -04:00
parent ba90a562c2
commit e6e96de0fd
47 changed files with 49 additions and 97 deletions

View File

@ -22,7 +22,7 @@
#include <wx/app.h> // to inherit
#include <wx/timer.h> // member variable
#include "MemoryX.h"
#include <memory>
class wxSingleInstanceChecker;
class wxSocketEvent;

View File

@ -17,6 +17,7 @@ Paul Licameli split from AudioIO.cpp
#include <wx/sstream.h>
#include <wx/txtstrm.h>
#include "MemoryX.h"
#include "Prefs.h"
#include "widgets/MeterPanelBase.h"

View File

@ -17,7 +17,7 @@
#if defined(EXPERIMENTAL_DEVICE_CHANGE_HANDLER)
#include "MemoryX.h"
#include <memory>
#if defined(__WXMSW__) || defined(__WXMAC__) || defined(HAVE_LIBUDEV_H)
#define HAVE_DEVICE_CHANGE

View File

@ -22,6 +22,7 @@ information.
#include <wx/intl.h>
#include "sndfile.h"
#include "Internat.h"
#include "MemoryX.h"
#include "widgets/AudacityMessageBox.h"
#include "Prefs.h"

View File

@ -17,7 +17,7 @@
#include "Identifier.h"
//#include <mutex>
#include "MemoryX.h"
#include <memory>
#include "sndfile.h"

View File

@ -11,7 +11,7 @@
#ifndef __AUDACITY_FILEIO__
#define __AUDACITY_FILEIO__
#include "MemoryX.h"
#include <memory>
class wxInputStream;
class wxOutputStream;

View File

@ -25,7 +25,7 @@ used throughout Audacity into this one place.
#include "MemoryX.h"
#include <memory>
#include <wx/app.h>
#include <wx/defs.h>

View File

@ -17,7 +17,7 @@
#include <wx/string.h> // function return value
#include "Identifier.h"
#include "Prefs.h"
#include "MemoryX.h"
#include <memory>
// Please try to support unlimited path length instead of using PLATFORM_MAX_PATH!
// Define one constant for maximum path value, so we don't have to do

View File

@ -11,7 +11,7 @@ Paul Licameli
#ifndef __AUDACITY_HIT_TEST_RESULT__
#define __AUDACITY_HIT_TEST_RESULT__
#include "MemoryX.h"
#include <memory>
#include "Internat.h" // for TranslatableString
class wxCursor;

View File

@ -8,11 +8,12 @@
**********************************************************************/
#include "MemoryX.h"
#include <memory>
#include <wx/defs.h>
class wxColour;
class wxImage;
class wxRect;
// This looks at the first pixel in the image, and shifts
// the entire image by the vector difference between that

View File

@ -10,64 +10,6 @@
#include <functional>
#if !(_MSC_VER >= 1800 || __cplusplus >= 201402L)
/* replicate the very useful C++14 make_unique for those build environments
that don't implement it yet.
typical usage:
auto p = std::make_unique<Myclass>(ctorArg1, ctorArg2, ... ctorArgN);
p->DoSomething();
auto q = std::make_unique<Myclass[]>(count);
q[0].DoSomethingElse();
The first hides naked NEW and DELETE from the source code.
The second hides NEW[] and DELETE[]. Both of course ensure destruction if
you don't use something like std::move(p) or q.release(). Both expressions require
that you identify the type only once, which is brief and less error prone.
(Whereas this omission of [] might invite a runtime error:
std::unique_ptr<Myclass> q { safenew Myclass[count] }; )
Some C++11 tricks needed here are (1) variadic argument lists and
(2) making the compile-time dispatch work correctly. You can't have
a partially specialized template function, but you get the effect of that
by other metaprogramming means.
*/
namespace std {
// For overloading resolution
template <typename X> struct __make_unique_result {
using scalar_case = unique_ptr<X>;
};
// Partial specialization of the struct for array case
template <typename X> struct __make_unique_result<X[]> {
using array_case = unique_ptr<X[]>;
using element = X;
};
// Now the scalar version of unique_ptr
template<typename X, typename... Args> inline
typename __make_unique_result<X>::scalar_case
make_unique(Args&&... args)
{
return typename __make_unique_result<X>::scalar_case
{ safenew X(forward<Args>(args)...) };
}
// Now the array version of unique_ptr
// The compile-time dispatch trick is that the non-existence
// of the scalar_case type makes the above overload
// unavailable when the template parameter is explicit
template<typename X> inline
typename __make_unique_result<X>::array_case
make_unique(size_t count)
{
return typename __make_unique_result<X>::array_case
{ safenew typename __make_unique_result<X>::element[count] };
}
}
#endif
/*
* ArrayOf<X>
* Not to be confused with std::array (which takes a fixed size) or std::vector

View File

@ -30,6 +30,7 @@ i.e. an alternative to the usual interface, for Audacity.
#include <wx/filename.h>
#include "FileNames.h"
#include "MemoryX.h"
#include "PluginManager.h"
#include "audacity/PluginInterface.h"

View File

@ -12,7 +12,7 @@
#ifndef __AUDACITY_MODULEMANAGER_H__
#define __AUDACITY_MODULEMANAGER_H__
#include "MemoryX.h"
#include <memory>
#include <map>
#include <vector>

View File

@ -61,6 +61,7 @@
#include "Internat.h"
#include "MemoryX.h"
#include <memory>
std::unique_ptr<FileConfig> ugPrefs {};

View File

@ -22,7 +22,7 @@ responsible for calling the appropriate callback functions.
#include "MemoryX.h"
#include <memory>
class AudacityCommand;
class LoadableModule;

View File

@ -14,7 +14,7 @@ class Track;
class TrackList;
class ViewInfo;
#include "ClientData.h"
#include "MemoryX.h"
#include <memory>
#include <vector>
// State relating to the set of selected tracks

View File

@ -77,6 +77,7 @@ can't be.
#include "Prefs.h"
#include "ImageManipulation.h"
#include "Internat.h"
#include "MemoryX.h"
#include "widgets/AudacityMessageBox.h"
// JKC: First get the MAC specific images.

View File

@ -13,7 +13,7 @@ Paul Licameli
#include "MemoryX.h"
#include <memory>
#include "TrackPanelDrawable.h" // to inherit
class AudacityProject;

View File

@ -11,7 +11,7 @@
#ifndef __AUDACITY_TRACK_PANEL_DRAWING_CONTEXT__
#define __AUDACITY_TRACK_PANEL_DRAWING_CONTEXT__
#include "MemoryX.h"
#include <memory>
class UIHandle;
using UIHandlePtr = std::shared_ptr<UIHandle>;

View File

@ -16,7 +16,7 @@ class wxMouseState;
class wxRect;
class wxSize;
class TrackPanelCell;
#include "MemoryX.h"
#include <memory>
// This is a hack so that the code that fakes a MOUSE_LEFT_BTN_UP on
// capture lost doesn't get in the way of handling MOUSE_RIGHT_BTN_UP.

View File

@ -12,7 +12,7 @@ Paul Licameli
#define __AUDACITY_UI_HANDLE__
#include <utility>
#include "MemoryX.h"
#include <memory>
#include "TrackPanelDrawable.h" // to inherit
class wxDC;
@ -26,8 +26,6 @@ class TrackPanelCell;
struct TrackPanelMouseEvent;
struct TrackPanelMouseState;
#include "MemoryX.h"
/// \brief Short-lived drawing and event-handling object associated with a TrackPanelCell
// A TrackPanelCell reports a handle object of some subclass, in response to a
// hit test at a mouse position; then this handle processes certain events,

View File

@ -16,7 +16,7 @@
#include <wx/event.h> // inherit wxEvtHandler
#include <wx/weakref.h> // member variable
#include "SelectedRegion.h"
#include "MemoryX.h"
#include <memory>
#include "ZoomInfo.h" // to inherit

View File

@ -19,7 +19,7 @@
#include <wx/event.h> // to declare custom event types
#include "../MemoryX.h"
#include <memory>
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, wxEVT_APP_COMMAND_RECEIVED, -1);

View File

@ -16,7 +16,8 @@
#ifndef __COMMANDBUILDER__
#define __COMMANDBUILDER__
#include "../MemoryX.h"
#include <memory>
#include <wx/string.h>
class AudacityProject;
class ResponseTarget;

View File

@ -16,7 +16,7 @@
#ifndef __COMMANDHANDLER__
#define __COMMANDHANDLER__
#include "../MemoryX.h"
#include <memory>
class AudacityApp;
class AudacityProject;
class AppCommandEvent;

View File

@ -55,8 +55,9 @@ and sends it to that message target.
#ifndef __COMMANDTARGETS__
#define __COMMANDTARGETS__
#include "../MemoryX.h"
#include <memory>
#include <vector>
#include <wx/string.h>
#include <wx/thread.h>
class wxStatusBar;

View File

@ -17,7 +17,7 @@
#include <functional>
#include <memory>
#include <unordered_map>
#include "../MemoryX.h"
#include <memory>
class AudacityCommand;

View File

@ -18,7 +18,7 @@
#include "../MemoryX.h"
#include <memory>
class wxString;

View File

@ -12,7 +12,7 @@ Max Maisel
#define __EBUR128_H__
#include "Biquad.h"
#include "MemoryX.h"
#include <memory>
#include "SampleFormat.h"
/// \brief Implements EBU-R128 loudness measurement.

View File

@ -13,7 +13,7 @@ Intrinsics (SSE/AVX) and Threaded Equalization
#ifdef EXPERIMENTAL_EQ_SSE_THREADED
#include "../MemoryX.h"
#include <memory>
#include <wx/thread.h> // to inherit
#include <audacity/Types.h>

View File

@ -16,7 +16,7 @@
#include <functional>
#include <memory>
#include <unordered_map>
#include "../MemoryX.h"
#include <memory>
class Effect;

View File

@ -12,7 +12,7 @@
#include "RealtimeEffectManager.h"
#include "audacity/EffectInterface.h"
#include "MemoryX.h"
#include <memory>
#include <atomic>
#include <wx/time.h>

View File

@ -56,7 +56,7 @@ of the warped region.
#ifndef __TIMEWARPER__
#define __TIMEWARPER__
#include "../MemoryX.h"
#include <memory>
class AUDACITY_DLL_API TimeWarper /* not final */
{

View File

@ -24,7 +24,7 @@
#include "VSTControlOSX.h"
#include "../../MemoryX.h"
#include <memory>
@interface VSTView : NSView
{

View File

@ -12,7 +12,7 @@
#ifndef LV2EFFECTSMODULE_H
#define LV2EFFECTSMODULE_H
#include "../../MemoryX.h"
#include <memory>
#include "lilv/lilv.h"

View File

@ -13,7 +13,7 @@
/* --------------------------------------------------------------------------*/
#include "../MemoryX.h"
#include <memory>
enum MP3RateMode : unsigned {
MODE_SET = 0,

View File

@ -10,7 +10,7 @@
#define __AUDACITY_IMPORT_FORWARDS__
#include <vector>
#include "../MemoryX.h"
#include <memory>
class ImportPlugin;
class UnusableImportPlugin;

View File

@ -11,7 +11,7 @@
#ifndef __AUDACITY_IMPORT_RAW__
#define __AUDACITY_IMPORT_RAW__
#include "../MemoryX.h"
#include <memory>
class AudacityProject;
class WaveTrackFactory;

View File

@ -17,6 +17,7 @@
#include <wx/defs.h>
#include "ToolBar.h"
#include "../MemoryX.h"
class wxCommandEvent;
class wxEraseEvent;

View File

@ -12,7 +12,7 @@ Paul Licameli split from TrackPanel.cpp
#define __AUDACITY_PLAY_INDICATOR_OVERLAY__
#include <wx/event.h> // to inherit
#include "../../MemoryX.h"
#include <memory>
#include "../../ClientData.h"
#include "../../widgets/Overlay.h" // to inherit

View File

@ -14,6 +14,7 @@ Paul Licameli
#include "../../UIHandle.h"
class wxMouseEvent;
class wxMouseState;
class LWSlider;
class Track;
class TranslatableString;

View File

@ -27,6 +27,7 @@
#include <wx/settings.h>
#include <wx/toplevel.h>
#include "../MemoryX.h"
#include "../SelectedRegion.h"
#if wxUSE_ACCESSIBILITY

View File

@ -17,7 +17,7 @@
#include "../MemoryX.h"
#include <memory>
#include "../../include/audacity/ComponentInterface.h"
#include <vector>
#include <wx/setup.h> // for wxUSE_* macros

View File

@ -10,6 +10,7 @@
#include "OverlayPanel.h"
#include "Overlay.h"
#include "../MemoryX.h"
#include <algorithm>
#include <wx/dcclient.h>

View File

@ -23,7 +23,7 @@ class wxCommandEvent;
#include <functional>
#include <vector>
#include <wx/menu.h> // to inherit wxMenu
#include "../MemoryX.h"
#include <memory>
#include "Internat.h"
#include "../commands/CommandManager.h"

View File

@ -11,7 +11,7 @@
#ifndef _WIDGETS_VALNUM_H_
#define _WIDGETS_VALNUM_H_
#include "../MemoryX.h"
#include <memory>
#include <wx/setup.h> // for wxUSE_* macros
#include <wx/defs.h>

View File

@ -9,7 +9,7 @@
#ifndef __AUDACITY_WXPANEL_WRAPPER__
#define __AUDACITY_WXPANEL_WRAPPER__
#include "../MemoryX.h"
#include <memory>
#include <wx/panel.h> // to inherit
#include <wx/dialog.h> // to inherit