mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
parent
ef3a6c4d4d
commit
9cf0fcf19d
|
@ -11632,7 +11632,7 @@ A key example is basic narrowing:
|
|||
|
||||
##### 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<int>(d); // OK: throws narrowing_error
|
||||
|
|
Loading…
Reference in New Issue
Block a user