[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 01:17:02 +0200 |
On Mon, 27 Aug 2018 23:06:23 +0000 Greg Chicares <address@hidden> wrote:
GC> On 2018-08-24 13:08, Vadim Zeitlin wrote:
GC> [...]
GC> > Honestly, I just hate this vector so much that I'd be glad to never use
GC> > it again. Just try to guess what does this do if you see it for the first
GC> > time:
GC> >
GC> > :allowed_(cardinality_of_the_enumeration, true)
GC> >
GC> > Using make_container_of_size() would be really much nicer in this, and
GC> > plenty of other, cases IMO.
GC>
GC> Not IMO though. Here's how I read it:
GC>
GC> - "cardinality" as the first argument of a two-argument vector::vector
GC> call strongly suggests it's the C++98 ctor.
Sorry, but how? I totally misread this as something else during the first
pass.
GC> - "allowed_" suggests boolean, so "true" looks like a default value.
To me it equally well suggested that cardinality_of_the_enumeration was
allowed. Of course, it's possible to find the correct meaning with a little
effort, but I assure you that it's not at all obvious from first glance at
the code.
GC> BTW, the actual type is
GC> std::deque<bool> allowed_;
GC> because at some time that was how I coded the not-a-container vector<bool>.
GC> But recently I used std::vector<int> for that purpose. Which is better IYO?
I'd use vector<bool> unless the code using really encountered one of the
problems it has. If not, vector<int> or vector<byte> would be less
confusing than a deque (I did wonder for quite some time why was it used
there...), although I'd still leave a comment explaining why is this type
used rather than vector<bool> -- and this is why I'd wait to get a problem
with the latter before replacing it, as otherwise I wouldn't have anything
to write in this comment...
Regards,
VZ
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, (continued)
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, Greg Chicares, 2018/08/22
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, Vadim Zeitlin, 2018/08/23
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, Greg Chicares, 2018/08/23
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, Vadim Zeitlin, 2018/08/23
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, Greg Chicares, 2018/08/23
- [lmi] Better unit tests, Vadim Zeitlin, 2018/08/23
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, Vadim Zeitlin, 2018/08/23
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, Greg Chicares, 2018/08/23
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, Vadim Zeitlin, 2018/08/24
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, Greg Chicares, 2018/08/27
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?,
Vadim Zeitlin <=
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, Greg Chicares, 2018/08/27
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, Vadim Zeitlin, 2018/08/28
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, Greg Chicares, 2018/08/23
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, Vadim Zeitlin, 2018/08/23
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, Greg Chicares, 2018/08/23
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, Vadim Zeitlin, 2018/08/24
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, Greg Chicares, 2018/08/27
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, Vadim Zeitlin, 2018/08/27
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, Greg Chicares, 2018/08/28
- Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?, Vadim Zeitlin, 2018/08/28