[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] [lmi-commits] master 9b3d0f1: Write explicitly-defaulted [cd]t

From: Greg Chicares
Subject: Re: [lmi] [lmi-commits] master 9b3d0f1: Write explicitly-defaulted [cd]tors inline, in class defn
Date: Sun, 5 Mar 2017 20:43:31 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0

On 2017-03-05 19:54, Vadim Zeitlin wrote:
> On Sun,  5 Mar 2017 14:28:23 -0500 (EST) Greg Chicares <address@hidden> wrote:
[...heavily trimmed...]
> GC> diff --git a/authenticity.hpp b/authenticity.hpp
> GC> index 447b8f6..0ae15ce 100644
> GC> --- a/authenticity.hpp
> GC> +++ b/authenticity.hpp
> GC> -    mutable calendar_date CachedDate_;
> GC> +    mutable calendar_date CachedDate_ = calendar_date(jdn_t(0));
>  Looking at this, I can't help returning to our discussion about using "="
> vs "()" vs "{}" because this type name repetition seems unfortunate and I'd
> clearly prefer to apply the following change here:
[...more heavy trimming...]
> -    mutable calendar_date CachedDate_ = calendar_date(jdn_t(0));
> +    mutable calendar_date CachedDate_{jdn_t(0)};
> Wouldn't you?

Yes, of course. It didn't even compile the first time because I wrote
    mutable calendar_date CachedDate_ = jdn_t(0);
which was okay in the (replaced) ctor-initializer, but not here.

Uniform initialization here would be like casting to auto: it tells
the compiler to do what it already knows how to do better than us.

> GC> -    double ScalarIMF_;
> GC> -    std::string ShortName_;
> GC> -    std::string LongName_;
> GC> -    std::string gloss_;
> GC> +    double      ScalarIMF_ = 0.0;
> GC> +    std::string ShortName_ = std::string();
> GC> +    std::string LongName_  = std::string();
> GC> +    std::string gloss_     = std::string();
> GC>  };
>  The last 3 new lines above also seem unnecessarily verbose to me, IMHO
> this is what default ctors are for and we could just omit the
> initialization entirely, but if we wanted to keep it for explicitness sake,
> I'd use "std::string ShortName_{};" etc here.

In this and the other examples you gave, I thought I was following
the rule we agreed on, e.g., here:

void input_sequence_test::check
    (char const*                     file
    ,char const*                     m = ""
    ,std::vector<std::string> const& k = std::vector<std::string>()
    ,std::vector<std::string> const& c = std::vector<std::string>()
    ,bool                            o = false
    ,std::string const&              w = std::string()

But even if I remember that correctly, there's no reason why our
thinking shouldn't evolve.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]