Skip to content

Commit 4a4047f

Browse files
Eugene Zelenkojeking3
authored andcommitted
Use BOOST_OVERRIDE to fix GCC -Wsuggest-override and Clang-tidy modernize-use-override warnings.
Also fix Clang-tidy readability-container-size-empty and readability-redundant-string-init warnings.
1 parent 90f12e1 commit 4a4047f

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

include/boost/contract/core/exception.hpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#ifndef BOOST_CONTRACT_EXCEPTION_HPP_
32
#define BOOST_CONTRACT_EXCEPTION_HPP_
43

@@ -96,16 +95,18 @@ class BOOST_CONTRACT_DETAIL_DECLSPEC bad_virtual_result_cast : // Copy (as str).
9695
9796
@b Throws: This is declared @c noexcept (or @c throw() before C++11).
9897
*/
99-
virtual ~bad_virtual_result_cast()
100-
/** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */;
98+
~bad_virtual_result_cast()
99+
/** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */
100+
BOOST_OVERRIDE;
101101

102102
/**
103103
Description for this error (containing both from- and to- type names).
104104
105105
@b Throws: This is declared @c noexcept (or @c throw() before C++11).
106106
*/
107-
virtual char const* what() const
108-
/** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */;
107+
char const* what() const
108+
/** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */
109+
BOOST_OVERRIDE;
109110

110111
/** @cond */
111112
private:
@@ -166,8 +167,9 @@ class BOOST_CONTRACT_DETAIL_DECLSPEC assertion_failure : // Copy (as str, etc.).
166167
167168
@b Throws: This is declared @c noexcept (or @c throw() before C++11).
168169
*/
169-
virtual ~assertion_failure()
170-
/** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */;
170+
~assertion_failure()
171+
/** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */
172+
BOOST_OVERRIDE;
171173

172174
/**
173175
String describing the failed assertion.
@@ -180,8 +182,9 @@ class BOOST_CONTRACT_DETAIL_DECLSPEC assertion_failure : // Copy (as str, etc.).
180182
File, line, and code will be omitted from this string if they were
181183
not specified when constructing this object.
182184
*/
183-
virtual char const* what() const
184-
/** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */;
185+
char const* what() const
186+
/** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */
187+
BOOST_OVERRIDE;
185188

186189
/**
187190
Name of the file containing the assertion.
@@ -956,4 +959,3 @@ from_failure_handler const& set_invariant_failure(from_failure_handler const& f)
956959
} } // namespace
957960

958961
#endif // #include guard
959-

include/boost/contract/detail/inlined/core/exception.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ BOOST_CONTRACT_DETAIL_DECLINLINE
7979
void assertion_failure::init() {
8080
std::ostringstream text;
8181
text << "assertion";
82-
if(std::string(code_) != "") text << " \"" << code_ << "\"";
82+
if(!std::string(code_).empty()) text << " \"" << code_ << "\"";
8383
text << " failed";
84-
if(std::string(file_) != "") {
84+
if(!std::string(file_).empty()) {
8585
text << ": file \"" << file_ << "\"";
8686
if(line_ != 0) text << ", line " << line_;
8787
}
@@ -101,7 +101,7 @@ namespace exception_ {
101101

102102
template<failure_key Key>
103103
void default_handler() {
104-
std::string k = "";
104+
std::string k;
105105
switch(Key) {
106106
case check_failure_key: k = "check "; break;
107107
case pre_failure_key: k = "precondition "; break;

0 commit comments

Comments
 (0)