Use unique_ptr for d-pointers (#1095)

* clang-tidy: make deleted members public

One oversight of modernize-use-equals-delete is that the C++11 way of
doing this is to make it public, which makes the warning still trigger.

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* clang-tidy: add missing deleted functions

Found with cppcoreguidelines-special-member-functions

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* unique_ptr conversions

unique_ptr is a safer and cleaner way to handle d pointers.

Also added missing = default.

Signed-off-by: Rosen Penev <rosenp@gmail.com>

---------

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev
2023-08-07 13:08:40 -07:00
committed by GitHub
parent 843a8aac80
commit 185bb7042e
183 changed files with 836 additions and 835 deletions

View File

@ -48,7 +48,7 @@ public:
IT::File::File(FileName file, bool readProperties,
AudioProperties::ReadStyle propertiesStyle) :
Mod::FileBase(file),
d(new FilePrivate(propertiesStyle))
d(std::make_unique<FilePrivate>(propertiesStyle))
{
if(isOpen())
read(readProperties);
@ -57,16 +57,13 @@ IT::File::File(FileName file, bool readProperties,
IT::File::File(IOStream *stream, bool readProperties,
AudioProperties::ReadStyle propertiesStyle) :
Mod::FileBase(stream),
d(new FilePrivate(propertiesStyle))
d(std::make_unique<FilePrivate>(propertiesStyle))
{
if(isOpen())
read(readProperties);
}
IT::File::~File()
{
delete d;
}
IT::File::~File() = default;
Mod::Tag *IT::File::tag() const
{

View File

@ -65,6 +65,9 @@ namespace TagLib {
*/
~File() override;
File(const File &) = delete;
File &operator=(const File &) = delete;
Mod::Tag *tag() const override;
/*!
@ -81,15 +84,11 @@ namespace TagLib {
*/
bool save() override;
private:
File(const File &) = delete;
File &operator=(const File &) = delete;
void read(bool readProperties);
class FilePrivate;
FilePrivate *d;
std::unique_ptr<FilePrivate> d;
};
} // namespace IT
} // namespace TagLib

View File

@ -70,14 +70,11 @@ public:
IT::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) :
AudioProperties(propertiesStyle),
d(new PropertiesPrivate())
d(std::make_unique<PropertiesPrivate>())
{
}
IT::Properties::~Properties()
{
delete d;
}
IT::Properties::~Properties() = default;
int IT::Properties::channels() const
{

View File

@ -54,6 +54,9 @@ namespace TagLib {
Properties(AudioProperties::ReadStyle propertiesStyle);
~Properties() override;
Properties(const Properties &) = delete;
Properties &operator=(const Properties &) = delete;
int channels() const override;
unsigned short lengthInPatterns() const;
@ -89,11 +92,8 @@ namespace TagLib {
void setPitchWheelDepth(unsigned char pitchWheelDepth);
private:
Properties(const Properties&) = delete;
Properties &operator=(const Properties&) = delete;
class PropertiesPrivate;
PropertiesPrivate *d;
std::unique_ptr<PropertiesPrivate> d;
};
} // namespace IT
} // namespace TagLib