From 2dc6d0d5ea93e1cc47e372bf142e46a9158ce51c Mon Sep 17 00:00:00 2001 From: Herb Sutter Date: Thu, 8 Jul 2021 11:21:41 -0700 Subject: [PATCH] Elaborated that we can't generally add comparison operators to C structs --- CppCoreGuidelines.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 08e0743..d8d89f9 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -4565,6 +4565,10 @@ In particular, if a concrete type is copyable, prefer to also give it an equalit ##### Note +For structs intended to be shared with C code, defining `operator==` may not be feasible. + +##### Note + Handles for resources that cannot be cloned, e.g., a `scoped_lock` for a `mutex`, are concrete types but typically cannot be copied (instead, they can usually be moved), so they can't be regular; instead, they tend to be move-only.