Merge pull request #1003 from kiwix/nodiscard_aarch64

Do not use `[[nodiscard]]` attribute on compiler not supporting it.
This commit is contained in:
Kelson 2023-10-16 15:19:53 +02:00 committed by GitHub
commit 0eb9a06736
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 1 deletions

View File

@ -186,6 +186,17 @@ class MultiKeyCache;
using LibraryPtr = std::shared_ptr<Library>; using LibraryPtr = std::shared_ptr<Library>;
using ConstLibraryPtr = std::shared_ptr<const Library>; using ConstLibraryPtr = std::shared_ptr<const Library>;
// Some compiler we use don't have [[nodiscard]] attribute.
// We don't want to declare `create` with it in this case.
#define LIBKIWIX_NODISCARD
#if defined __has_cpp_attribute
#if __has_cpp_attribute (nodiscard)
#undef LIBKIWIX_NODISCARD
#define LIBKIWIX_NODISCARD [[nodiscard]]
#endif
#endif
/** /**
* A Library store several books. * A Library store several books.
*/ */
@ -201,7 +212,7 @@ class Library: public std::enable_shared_from_this<Library>
Library(); Library();
public: public:
[[nodiscard]] static LibraryPtr create() { LIBKIWIX_NODISCARD static LibraryPtr create() {
return LibraryPtr(new Library()); return LibraryPtr(new Library());
} }
~Library(); ~Library();
@ -408,6 +419,10 @@ private: //data
std::unique_ptr<Xapian::WritableDatabase> m_bookDB; std::unique_ptr<Xapian::WritableDatabase> m_bookDB;
}; };
// We don't need it anymore and we don't want to polute any other potential usage
// of `LIBKIWIX_NODISCARD` token.
#undef LIBKIWIX_NODISCARD
} }