lmi
[Top][All Lists]
Advanced

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

Re: [lmi] Switch to using C++11 uniform initialization in the ctor initi


From: Vadim Zeitlin
Subject: Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?
Date: Tue, 28 Aug 2018 12:13:57 +0200

On Tue, 28 Aug 2018 00:52:24 +0000 Greg Chicares <address@hidden> wrote:

GC> On 2018-08-27 23:17, Vadim Zeitlin wrote:
GC> > On Mon, 27 Aug 2018 23:06:23 +0000 Greg Chicares <address@hidden> wrote:
GC> [...]
GC> > GC> - "cardinality" as the first argument of a two-argument vector::vector
GC> > GC> call strongly suggests it's the C++98 ctor.
GC> > 
GC> >  Sorry, but how? I totally misread this as something else during the first
GC> > pass.
GC> 
GC> Is there a synonym that would make it more clear? E.g.:
GC> 
GC>   :allowed_(number_of_enumerators_in_the_enumeration, true)
GC> 
GC>   :allowed_(size_of_the_vector_we_are_constructing, true)
GC> 
GC> Or is there some other way to signal that we're passing a size argument? 
E.g.:
GC> 
GC>   :allowed_((lmi::ssize_t)cardinality_of_the_enumeration, true)

 Adding custom types such as size_of_the_vector and vector_element_value
would definitely make this initialization much more clear:

      :allowed_
          (size_of_the_vector(cardinality_of_the_enumeration)
          ,vector_element_value(true)
          )

but I don't really see it as being better to the previously proposed
function call and it still requires using parentheses rather than braces.

 So IMO if the goal is to make the code as readable and unambiguous as
possible, the function approach is still the best. The real choice is
between pursuing readability at any price or preferring brevity to it.

 Regards,
VZ


reply via email to

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