mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-09 08:31:13 +02:00
More changes to Audacity.h to hide new and delete from code sweeps...
... changed some comments, and hid = delete in a macro. That is a new C++11 feature that lets you stipulate that a class suppresses an otherwise inherited or generated name.
This commit is contained in:
parent
d9c2ff6dc2
commit
9e5d31d347
@ -28,8 +28,8 @@ struct AboutDialogCreditItem {
|
||||
{}
|
||||
|
||||
// No copy
|
||||
AboutDialogCreditItem(const AboutDialogCreditItem&) = delete;
|
||||
AboutDialogCreditItem& operator= (const AboutDialogCreditItem&) = delete;
|
||||
AboutDialogCreditItem(const AboutDialogCreditItem&) PROHIBITED;
|
||||
AboutDialogCreditItem& operator= (const AboutDialogCreditItem&) PROHIBITED;
|
||||
|
||||
// Move constructor, because wxString lacks one
|
||||
AboutDialogCreditItem(AboutDialogCreditItem &&moveMe)
|
||||
|
@ -164,9 +164,12 @@ void QuitAudacity();
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
// Reviewed, certified, non-leaky uses of new that immediately entrust their results to RAII objects.
|
||||
// You may use it in new code when constructing a wxWindow subclass with non-NULL parent window.
|
||||
// You may use it in new code when the new expression is the constructor argument for a standard smart
|
||||
// This renames a good use of this C++ keyword that we don't need to review when hunting for leaks.
|
||||
#define PROHIBITED = delete
|
||||
|
||||
// Reviewed, certified, non-leaky uses of NEW that immediately entrust their results to RAII objects.
|
||||
// You may use it in NEW code when constructing a wxWindow subclass with non-NULL parent window.
|
||||
// You may use it in NEW code when the NEW expression is the constructor argument for a standard smart
|
||||
// pointer like std::unique_ptr or std::shared_ptr.
|
||||
#define safenew new
|
||||
|
||||
@ -181,8 +184,8 @@ void QuitAudacity();
|
||||
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
|
||||
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.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user