[Libreoffice-bugs] [Bug 131117] Don't use static_cast with numeric literals

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Wed Mar 4 12:48:24 UTC 2020


https://bugs.documentfoundation.org/show_bug.cgi?id=131117

--- Comment #3 from Mike Kaganski <mikekaganski at hotmail.com> ---
(In reply to Stephan Bergmann from comment #2)
> Semantically, both static_cast and functional cast are fine there, and have
> the exact same meaning. 

Well, from C++ language PoV; while I rather meant intended usage (having read
the rationale for choosing those long and awkward names like "static_cast" and
"reinterpret_cast" to show explicit intention to change type of something,
which is usually a sign of a low-level manipulation, a legacy code, or may be
possibly implemented better).

> Syntactically, functional cast can only be used if
> wanted_type is a simple-type-specifier (e.g., it cannot be used if
> wanted_type is "unsigned long").

Works fine for me with unsigned long(9) or unsigned short(9) in VS2019, and
tested to produce the results of necessary type (e.g. in templated functions
with deduced params, like std::max)

> Apart from that, I at least have no clear
> preference for either (functional cast is less verbose, though), and am not
> sure whether such a cosmetic clean-up is worth it and wanted.

I personally dislike seeing those "static_casts" for what is not casting of
value of one type to another type. I felt it a really easy hack for those who
might want something very trivial to start. However, I don't mind closing this
(and I added you to CC to learn your opinion on this).

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20200304/8d2648d5/attachment.htm>


More information about the Libreoffice-bugs mailing list