Boost logo

Boost :

Subject: Re: [boost] boost mapped_file issue
From: Lars Viklund (zao_at_[hidden])
Date: 2011-11-02 05:42:33

On Tue, Nov 01, 2011 at 06:39:18PM -0700, dophine wrote:
> Hi all,
> I try to use memory map file. However, I don't know why the readsome return
> 0. It is fine if I use getline.

readsome on streams is generally a suboptimal idea unless you ensure
that somehow, there's data in the rdbuf. If it's empty, readsome will
not ever produce anything new.

Personally, I really dislike the choice of "some" in the function name,
as it for some reason makes it the first choice for people who don't
know the difference between read and readsome.

Unless you need the non-blockingness of readsome and are prepared to
handle all the work around it, use read.

Also note that eof() won't be true until _after_ a read past the end has
failed, so your iteration, had it worked, would have erroneously
processed one iteration too much.

Lars Viklund | zao_at_[hidden]

Boost list run by bdawes at, gregod at, cpdaniel at, john at