Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit af80786

Browse files
committed
fix: violations of the rule of 5
I.e. explicitly declare all special member functions or none. It is okay to implicitly cause the copy operators to be removed by defining the move operators or vice versa.
1 parent f673ff0 commit af80786

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

.clang-tidy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@ CheckOptions:
2121
- { key: readability-braces-around-statements.ShortStatementLines, value: 3 }
2222
- { key: readability-implicit-bool-conversion.AllowPointerConditions, value: true }
2323
- { key: readability-implicit-bool-conversion.AllowIntegerConditions, value: true }
24+
- { key: cppcoreguidelines-special-member-functions.AllowImplicitlyDeletedCopyOrMove, value: true }
25+
- { key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted, value: true }
2426

2527
HeaderFilterRegex: '.*/(src/.*|include/.*)[.]hpp'

include/awesome/assert.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ namespace AwesomeAssert
7272
virtual ~stringifier() noexcept;
7373
virtual std::ostream& convert(std::ostream& os) const = 0;
7474

75+
protected:
76+
stringifier() = default;
77+
stringifier(stringifier&&) = default;
78+
stringifier& operator=(stringifier&&) = default;
79+
7580
private:
7681
friend struct detail::bool_expression;
7782
// Must be inline to ensure the compiler has the full body available for constant propagation
@@ -264,9 +269,6 @@ namespace AwesomeAssert
264269
{
265270
}
266271

267-
bool_expression(bool_expression&& rhs) = default;
268-
bool_expression& operator=(bool_expression&& rhs) = default;
269-
270272
AWESOME_CXX23_CONSTEXPR const_iterator begin() const noexcept
271273
{
272274
return const_iterator{fail_expression.get()};
@@ -610,7 +612,6 @@ namespace AwesomeAssert
610612
struct violation_info
611613
{
612614
violation_info() = default;
613-
violation_info(violation_info&& rhs) = default;
614615

615616
AWESOME_CXX23_CONSTEXPR violation_info(
616617
const char* file

test/simple.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct move_only_t
3636

3737
move_only_t(move_only_t&&) = default;
3838
move_only_t& operator=(move_only_t&&) = default;
39+
~move_only_t() = default;
3940

4041
// modifying operators are purposefully by-value to force the params to be r-values.
4142
friend constexpr move_only_t operator<<(move_only_t lhs, move_only_t rhs) noexcept

0 commit comments

Comments
 (0)