[Nfd-dev] code style rule 44
Alex Afanasyev
alexander.afanasyev at ucla.edu
Sat Feb 15 20:31:07 PST 2014
There are some general cases when implicit conversion is standard and does not require any comment. For example, it is the case with "const std::string&" parameter and all safe value preserving integer upconversions (from uint8 to uint32, etc.).
---
Alex
On Feb 15, 2014, at 8:17 PM, Junxiao Shi <shijunxiao at email.arizona.edu> wrote:
> Dear folks
>
> Implicit conversion between integer and floating point numbers can cause problems and should be avoided.
>
> Implicit conversion in single-argument constructor is usually undesirable. Therefore, all single-argument constructors should be marked 'explicit', unless implicit conversion IS desirable. In the few cases that implicit conversion is desirable, a comment should be placed near the constructor documenting the reason.
>
> Yours, Junxiao
>
> On Sat, Feb 15, 2014 at 8:52 PM, Alex Afanasyev <alexander.afanasyev at ucla.edu> wrote:
> This rule is very strange and I don't like following it. Implicit conversions generally a good thing. For the cases implicit conversion is undesirable, constructors should be mark explicit.
>
> I don't see problems with any of the listed examples, except with enum (some compiler may issue warnings).
>
> I prefer not considering this rule for us.
>
> ---
> Alex
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/nfd-dev/attachments/20140215/e4ea8f8d/attachment.html>
More information about the Nfd-dev
mailing list