[Top][All Lists]

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

Re: [Monotone-devel] Two new lists to get commit logs

From: Nathan Myers
Subject: Re: [Monotone-devel] Two new lists to get commit logs
Date: Sun, 17 Apr 2005 16:25:30 -0700
User-agent: Mutt/1.3.28i

On Sun, Apr 17, 2005 at 03:05:43PM -0700, Nathaniel Smith wrote:
> ... it helps if your existing guess_binary function
> doesn't contain a C-style string of "characters that imply binary", of
> which the first element is NUL ;-)

Who would use a null-terminated string for anything in a C++ program?
Here's a handy idiom:

  template <unsigned N>
    int f(const char (&a)[N])
      { return ::write(1, a, N-1); }

  int main() { return f("abc\n"); }

The template engine deduces the size of the literal string and binds N
to that value, so you don't need to search for any dumb terminator.
Better yet, if you call f with a pointer, the compiler rejects it.

Nathan Myers

reply via email to

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