Resolve compiler warnings (#302)

* build: replace class noncopyable by C++11 deleted function declaration

C++11 is mandatory since commit v0.9.2-48-g8564b2f8, therefore we can
exercise the =delete keyword in class declarations to prohibit
copying.

* build: resolve -Woverloaded-virtual warnings

context.hpp:109:26: warning: "virtual vmime::context&
vmime::context::operator=(const vmime::context&)’ was hidden
[-Woverloaded-virtual=]
  109 |         virtual context& operator=(const context& ctx);
      |                          ^~~~~~~~
generationContext.hpp:153:28: note:   by ‘vmime::generationContext&
vmime::generationContext::operator=(const vmime::generationContext&)’
  153 |         generationContext& operator=(const generationContext& ctx);
      |                            ^~~~~~~~

AFAICS, there is no point in having "virtual" on an assignment operator.
Any derived classes' operator= has different signature anyway.
It is also the only class with a virtual operator=, so that's an indicator
for oddness as well.

* build: resolve -Wdeprecated-declarations warnings

encoding.cpp: In static member function "static const vmime::encoding
vmime::encoding::decideImpl(std::__cxx11::basic_string<char>::const_iterator,
std::__cxx11::basic_string<char>::const_iterator)":

encoding.cpp:161:29: warning: "std::binder2nd<_Operation>
std::bind2nd(const _Operation&, const _Tp&) [with _Operation =
less<unsigned char>; _Tp = int]" is deprecated: use "std::bind" instead
[-Wdeprecated-declarations]
  161 |                 std::bind2nd(std::less<unsigned char>(), 127)
      |                 ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

C++11 is mandatory, so just use a lambda already.
This commit is contained in:
Jan Engelhardt 2024-05-21 15:41:50 +02:00 committed by GitHub
parent d03ad5f0f6
commit 15f3b94580
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 23 deletions

View File

@ -232,23 +232,6 @@ namespace vmime {
return const_pointer_cast <X, Y>(obj);
}
/** Inherit from this class to indicate the subclass is not copyable,
* ie. you want to prohibit copy construction and copy assignment.
*/
class VMIME_EXPORT noncopyable {
protected:
noncopyable() { }
virtual ~noncopyable() { }
private:
noncopyable(const noncopyable&);
void operator=(const noncopyable&);
};
} // vmime

View File

@ -106,7 +106,7 @@ protected:
context();
context(const context& ctx);
virtual context& operator=(const context& ctx);
context& operator=(const context& ctx);
void copyFrom(const context& ctx);
bool m_internationalizedEmail;

View File

@ -157,9 +157,7 @@ const encoding encoding::decideImpl(
const string::difference_type length = end - begin;
const string::difference_type count = std::count_if(
begin, end,
std::bind2nd(std::less<unsigned char>(), 127)
);
begin, end, [](unsigned char x) { return x < 127; });
// All is in 7-bit US-ASCII --> 7-bit (or Quoted-Printable...)
if (length == count) {

View File

@ -38,9 +38,12 @@ namespace utility {
/** Base class for input/output stream.
*/
class VMIME_EXPORT stream : public object, private noncopyable {
class VMIME_EXPORT stream : public object {
public:
stream() = default;
/* Presence of move-ctor/move-asg inhibits default copy-ctor/copy-asg */
stream(stream &&) = default;
stream &operator=(stream &&) = default;
virtual ~stream() { }