mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 12:44:42 +03:00
committed by
Jonathan Wakely
parent
ef3a6c4d4d
commit
9cf0fcf19d
@@ -11632,7 +11632,7 @@ A key example is basic narrowing:
|
|||||||
|
|
||||||
##### Note
|
##### Note
|
||||||
|
|
||||||
The guideline support library offers a `narrow` operation for specifying that narrowing is acceptable and a `narrow` ("narrow if") that throws an exception if a narrowing would throw away information:
|
The guideline 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:
|
||||||
|
|
||||||
i = narrow_cast<int>(d); // OK (you asked for it): narrowing: i becomes 7
|
i = narrow_cast<int>(d); // OK (you asked for it): narrowing: i becomes 7
|
||||||
i = narrow<int>(d); // OK: throws narrowing_error
|
i = narrow<int>(d); // OK: throws narrowing_error
|
||||||
|
|||||||
Reference in New Issue
Block a user