From this answer to the question "When should static_cast, dynamic_cast, const_cast and reinterpret_cast be used?":
C-style cast and function-style cast are casts using (type)object
or type(object)
, respectively.
It then begins to list the behavior of the C-style cast, but never tells whether the function-style cast is identical or not.
I'm asking because Resharper for C++ warns me in case of C-style casts but does not warn me in case of function-style casts:
In what way is the the function-style case different from the C-style cast? Or, if they are identical, is it a bug in Resharper and it should emit a warning, too? Is int(d)
safe to use? It looks much simpler than the suggested static_cast<int>(d);
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…