Source: Fix Clang -Wdeprecated warnings

Applied C++ 'rule of three'.
This commit is contained in:
Sean McBride
2021-10-14 12:13:23 -04:00
parent 315fc296e3
commit e2a4718d18
6 changed files with 23 additions and 14 deletions

View File

@@ -59,6 +59,8 @@ public:
}
virtual ~cmCTestCommand() = default;
cmCTestCommand(const cmCTestCommand&) = default;
cmCTestCommand& operator=(const cmCTestCommand&) = default;
bool operator()(std::vector<cmListFileArgument> const& args,
cmExecutionStatus& status)

View File

@@ -60,18 +60,20 @@ public:
class Preset
{
public:
#if __cplusplus < 201703L && (!defined(_MSVC_LANG) || _MSVC_LANG < 201703L)
Preset() = default;
Preset(Preset&& /*other*/) = default;
Preset(const Preset& /*other*/) = default;
Preset& operator=(const Preset& /*other*/) = default;
virtual ~Preset() = default;
#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
Preset& operator=(Preset&& /*other*/) = default;
#else
// The move assignment operators for several STL classes did not become
// noexcept until C++17, which causes some tools to warn about this move
// assignment operator throwing an exception when it shouldn't. Disable the
// move assignment operator until C++17 is enabled.
// Explicitly defining a copy assignment operator prevents the compiler
// from automatically generating a move assignment operator.
Preset& operator=(const Preset& /*other*/) = default;
// assignment operator throwing an exception when it shouldn't.
Preset& operator=(Preset&& /*other*/) = delete;
#endif
virtual ~Preset() = default;
std::string Name;
std::vector<std::string> Inherits;
bool Hidden;

View File

@@ -24,6 +24,8 @@ public:
#endif
cmFileTime() = default;
~cmFileTime() = default;
cmFileTime(const cmFileTime&) = default;
cmFileTime& operator=(const cmFileTime&) = default;
/**
* @brief Loads the file time of fileName from the file system

View File

@@ -26,6 +26,9 @@ public:
cmSearchPath(cmFindCommon* findCmd = nullptr);
~cmSearchPath();
cmSearchPath(const cmSearchPath&) = default;
cmSearchPath& operator=(const cmSearchPath&) = default;
const std::vector<std::string>& GetPaths() const { return this->Paths; }
std::size_t size() const { return this->Paths.size(); }

View File

@@ -42,7 +42,7 @@ codecvt::codecvt(Encoding e)
codecvt::~codecvt() = default;
bool codecvt::do_always_noconv() const throw()
bool codecvt::do_always_noconv() const noexcept
{
return this->m_noconv;
}
@@ -234,12 +234,12 @@ void codecvt::BufferPartial(mbstate_t& state, int size,
}
#endif
int codecvt::do_max_length() const throw()
int codecvt::do_max_length() const noexcept
{
return 4;
}
int codecvt::do_encoding() const throw()
int codecvt::do_encoding() const noexcept
{
return 0;
}

View File

@@ -24,14 +24,14 @@ public:
protected:
~codecvt() override;
bool do_always_noconv() const throw() override;
bool do_always_noconv() const noexcept override;
result do_out(mbstate_t& state, const char* from, const char* from_end,
const char*& from_next, char* to, char* to_end,
char*& to_next) const override;
result do_unshift(mbstate_t& state, char* to, char*,
char*& to_next) const override;
int do_max_length() const throw() override;
int do_encoding() const throw() override;
int do_max_length() const noexcept override;
int do_encoding() const noexcept override;
private:
// The mbstate_t argument to do_out and do_unshift is responsible