From 9a95f97f448b7196646fdcca69fc365a37c39014 Mon Sep 17 00:00:00 2001 From: Sergey Zubkov Date: Mon, 8 Aug 2022 15:19:42 -0400 Subject: [PATCH] C.168: switch example to op+ to avoid side tracking about defaults (closes #1955) --- CppCoreGuidelines.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 9d14c56..b172a7c 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -8513,23 +8513,21 @@ Avoiding inconsistent definition in different namespaces ##### Example struct S { }; - bool operator==(S, S); // OK: in the same namespace as S, and even next to S + S operator+(S, S); // OK: in the same namespace as S, and even next to S S s; - bool x = (s == s); - -This is what a default `==` would do, if we had such defaults. + S r = s + s; ##### Example namespace N { struct S { }; - bool operator==(S, S); // OK: in the same namespace as S, and even next to S + S operator+(S, S); // OK: in the same namespace as S, and even next to S } N::S s; - bool x = (s == s); // finds N::operator==() by ADL + S r = s + s; // finds N::operator+() by ADL ##### Example, bad