[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] [PATCH] C++ m11n: range-based for loops
From: |
Vadim Zeitlin |
Subject: |
Re: [lmi] [PATCH] C++ m11n: range-based for loops |
Date: |
Tue, 17 Jan 2017 14:54:49 +0100 |
On Tue, 17 Jan 2017 01:59:59 +0000 Greg Chicares <address@hidden> wrote:
GC> On 2017-01-16 17:20, Vadim Zeitlin wrote:
...
GC> > BTW, I find it useful to have some kind of "once only" helper class, e.g.
GC> [...]
GC> > and then use it like this:
GC> >
GC> > do_once_only skip_comma;
GC> > for(auto const& s : remaining)
GC> > {
GC> > if(!skip_comma)
GC> > message << ",";
GC> > message << " '" << s << "'";
GC> > }
GC>
GC> As for me, I'd implement this function thus:
GC>
GC> std::ostringstream oss;
GC> oss
GC> << "Checking columns: "
GC> << insert_commas_between_elements(quote_elements(remaining))
GC> << " not found."
GC> ;
GC>
GC> avoiding the 'first' and 'only_one' special cases. But of course TIMTOWTDI.
Having a helper insert_commas_between_elements() or
insert_separator_between_elements() function could be useful too, of
course, but IME such generic do_once_only class can be useful in other,
quite different, situations too. I even thought I saw another loop that had
to do something special (but [not] inserting a separator) in lmi code, but
somehow can't find it right now. Maybe you'll notice it when reviewing the
rest of the changes...
Regards,
VZ
- Re: [lmi] [PATCH] C++ m11n: range-based for loops, (continued)
- Re: [lmi] [PATCH] C++ m11n: range-based for loops, Greg Chicares, 2017/01/13
- Re: [lmi] [PATCH] C++ m11n: range-based for loops, Greg Chicares, 2017/01/14
- Re: [lmi] [PATCH] C++ m11n: range-based for loops, Vadim Zeitlin, 2017/01/15
- Re: [lmi] [PATCH] C++ m11n: range-based for loops, Greg Chicares, 2017/01/15
- Re: [lmi] [PATCH] C++ m11n: range-based for loops, Vadim Zeitlin, 2017/01/15
- Re: [lmi] [PATCH] C++ m11n: range-based for loops, Greg Chicares, 2017/01/16
- Re: [lmi] [PATCH] C++ m11n: range-based for loops, Vadim Zeitlin, 2017/01/16
- Re: [lmi] [PATCH] C++ m11n: range-based for loops, Greg Chicares, 2017/01/16
- Re: [lmi] [PATCH] C++ m11n: range-based for loops,
Vadim Zeitlin <=
- Re: [lmi] [PATCH] C++ m11n: range-based for loops, Greg Chicares, 2017/01/18
- Re: [lmi] [PATCH] C++ m11n: range-based for loops, Greg Chicares, 2017/01/19
- Re: [lmi] [PATCH] C++ m11n: range-based for loops, Vadim Zeitlin, 2017/01/20
- Re: [lmi] [PATCH] C++ m11n: range-based for loops, Greg Chicares, 2017/01/20
- Re: [lmi] [PATCH] C++ m11n: range-based for loops, Vadim Zeitlin, 2017/01/20