[Top][All Lists]

[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:
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());

reply via email to

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