[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi] count_lines() [Was: Group premium quotes]
From: |
Greg Chicares |
Subject: |
[lmi] count_lines() [Was: Group premium quotes] |
Date: |
Wed, 19 Aug 2015 14:59:43 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.3.0 |
On 2015-08-16 17:07, Greg Chicares wrote:
> First of all, don't read this before September, especially not if you're
> on vacation.
I realize this may not matter much, but:
// Return the number of lines in a possibly multiline string.
std::size_t count_lines(std::string const& s)
{
return 1u + std::count(s.begin(), s.end(), '\n');
}
It looks like these string arguments:
"__1__\n__2__"
"__1__\n__2__\n"
would return different counts. Given the "1u +", I suppose we're assuming
that there's no trailing '\n', in which case we should at least document
that; but if it's worth documenting, it's worth asserting. Untested idea:
LMI_ASSERT(s.rend() && '\n' != *s.rend());
- Re: [lmi] Number of "eligibles" [Was: Group premium quotes], (continued)
- Re: [lmi] Number of "eligibles" [Was: Group premium quotes], Greg Chicares, 2015/08/26
- Re: [lmi] Number of "eligibles" [Was: Group premium quotes], Vadim Zeitlin, 2015/08/26
- Re: [lmi] Number of "eligibles" [Was: Group premium quotes], Greg Chicares, 2015/08/26
- Re: [lmi] Number of "eligibles" [Was: Group premium quotes], Vadim Zeitlin, 2015/08/27
- Re: [lmi] Number of "eligibles" [Was: Group premium quotes], Greg Chicares, 2015/08/28
[lmi] Vanishing menu underlines [Was: Group premium quotes], Greg Chicares, 2015/08/18
Re: [lmi] Group premium quotes, Vadim Zeitlin, 2015/08/18
[lmi] count_lines() [Was: Group premium quotes],
Greg Chicares <=
[lmi] Toolbar subtleties [Was: Group premium quotes], Greg Chicares, 2015/08/19
[lmi] Miscellanea [Was: Group premium quotes], Greg Chicares, 2015/08/19
Re: [lmi] Group premium quotes, Greg Chicares, 2015/08/26
Re: [lmi] [PATCH] Fix headers display (was: Group premium quotes), Vadim Zeitlin, 2015/08/27