[clang-tidy] use nodiscard (#234)

Found with modernize-use-nodiscard

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2020-07-27 22:40:16 -07:00 committed by GitHub
parent 5f43f4cbfe
commit 07f5cb24f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,6 +45,12 @@ THE SOFTWARE.
#define CXXOPTS_HAS_OPTIONAL #define CXXOPTS_HAS_OPTIONAL
#endif #endif
#if __cplusplus >= 201603L
#define CXXOPTS_NODISCARD [[nodiscard]]
#else
#define CXXOPTS_NODISCARD
#endif
#ifndef CXXOPTS_VECTOR_DELIMITER #ifndef CXXOPTS_VECTOR_DELIMITER
#define CXXOPTS_VECTOR_DELIMITER ',' #define CXXOPTS_VECTOR_DELIMITER ','
#endif #endif
@ -330,6 +336,7 @@ namespace cxxopts
{ {
} }
CXXOPTS_NODISCARD
const char* const char*
what() const noexcept override what() const noexcept override
{ {
@ -933,6 +940,7 @@ namespace cxxopts
public: public:
using abstract_value<T>::abstract_value; using abstract_value<T>::abstract_value;
CXXOPTS_NODISCARD
std::shared_ptr<Value> std::shared_ptr<Value>
clone() const clone() const
{ {
@ -1019,28 +1027,34 @@ namespace cxxopts
OptionDetails(OptionDetails&& rhs) = default; OptionDetails(OptionDetails&& rhs) = default;
CXXOPTS_NODISCARD
const String& const String&
description() const description() const
{ {
return m_desc; return m_desc;
} }
const Value& value() const { CXXOPTS_NODISCARD
const Value&
value() const {
return *m_value; return *m_value;
} }
CXXOPTS_NODISCARD
std::shared_ptr<Value> std::shared_ptr<Value>
make_storage() const make_storage() const
{ {
return m_value->clone(); return m_value->clone();
} }
CXXOPTS_NODISCARD
const std::string& const std::string&
short_name() const short_name() const
{ {
return m_short; return m_short;
} }
CXXOPTS_NODISCARD
const std::string& const std::string&
long_name() const long_name() const
{ {
@ -1101,6 +1115,7 @@ namespace cxxopts
m_value->parse(); m_value->parse();
} }
CXXOPTS_NODISCARD
size_t size_t
count() const noexcept count() const noexcept
{ {
@ -1108,6 +1123,7 @@ namespace cxxopts
} }
// TODO: maybe default options should count towards the number of arguments // TODO: maybe default options should count towards the number of arguments
CXXOPTS_NODISCARD
bool bool
has_default() const noexcept has_default() const noexcept
{ {
@ -1157,15 +1173,15 @@ namespace cxxopts
{ {
} }
const CXXOPTS_NODISCARD
std::string& const std::string&
key() const key() const
{ {
return m_key; return m_key;
} }
const CXXOPTS_NODISCARD
std::string& const std::string&
value() const value() const
{ {
return m_value; return m_value;