From 4498e078e71c23fe7ff8be562866c08101057961 Mon Sep 17 00:00:00 2001 From: Herb Sutter Date: Thu, 1 Apr 2021 12:01:33 -0700 Subject: [PATCH] Refined spec for `narrow` to cover signedness promotions, closes #1726 --- CppCoreGuidelines.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 2b81342..fa10073 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -11589,7 +11589,7 @@ A key example is basic narrowing: ##### Note -The guidelines support library offers a `narrow_cast` operation for specifying that narrowing is acceptable and a `narrow` ("narrow if") that throws an exception if a narrowing would throw away information: +The guidelines support library offers a `narrow_cast` operation for specifying that narrowing is acceptable and a `narrow` ("narrow if") that throws an exception if a narrowing would throw away legal values: i = narrow_cast(d); // OK (you asked for it): narrowing: i becomes 7 i = narrow(d); // OK: throws narrowing_error @@ -21021,7 +21021,7 @@ for example, `Expects(p)` will become `[[expects: p]]`. * `finally` // `finally(f)` makes a `final_action{f}` with a destructor that invokes `f` * `narrow_cast` // `narrow_cast(x)` is `static_cast(x)` -* `narrow` // `narrow(x)` is `static_cast(x)` if `static_cast(x) == x` or it throws `narrowing_error` +* `narrow` // `narrow(x)` is `static_cast(x)` if `static_cast(x) == x` with no signedness promotions, or it throws `narrowing_error` (e.g., `narrow(-42)` throws) * `[[implicit]]` // "Marker" to put on single-argument constructors to explicitly make them non-explicit. * `move_owner` // `p = move_owner(q)` means `p = q` but ??? * `joining_thread` // a RAII style version of `std::thread` that joins. -- GitLab