-
Notifications
You must be signed in to change notification settings - Fork 735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
throwing copy and move constructors cause final_act to not execute the action #283
Comments
Can I work on this issue? |
@jack17529 Sure! Feel free to put together a PR. |
throwing moves are oddities: see rule C.66 |
In a language where a "move" may in fact be a copy, probably not as odd as one might hope. |
The Core Guidelines are focusing on helping "ordinary" programmers, as the expense of failing at language lawyering. There is a clear and bright distinction between a copy constructor and a move constructor. A move isn't a copy, and that is the primary and higher order bits that should be most helpful to most programmers. |
@neilmacintosh , this may sound silly but I have never used narrow_cast , can you please explain me this line - https://github.com/Microsoft/GSL/blob/master/include/gsl/gsl_util#L108 |
@jack17529 Sure. (and questions are always welcome and never silly ;-)) If you look just a few lines up in the same file, you'll see that |
@neilmacintosh Narrower data type means for eg. casting it from 16 bit type to 8 bit type then 8bit bit data type will be narrow data type and it will also depend on weather the data type is unsigned or signed.Because it is like static_cast thus it must be type safe.If there is an exception then it will produce narrowing_error. Is it right what I understood. |
@jack17529 yes, you have it pretty much right there. Casting from a type with a larger number of bits to smaller is definitely the simplest example. However, even going between signed and unsigned variants of the same type can "narrow", because each allows different value ranges. Note that only using |
We are having problem in this move ctor - and this more specifically - Am I right in doing so ? |
Maintainers' call: The code this issue refers to has considerably changed, sorry for the delay. |
The constructor of
final_act
here moves from argumentf
into memberf_
. If that throws, then the action is not executed, which is kinda the whole point of this utility. This paper shows how to do it right.The text was updated successfully, but these errors were encountered: