Boost logo

Boost :

Subject: Re: [boost] [outcome v2] Please comment on new result<T, EC> reference API docs
From: Peter Dimov (lists_at_[hidden])
Date: 2017-06-23 00:25:58

Niall Douglas wrote:

> However I am thinking here in terms of WG21 standardisation, specifically
> SG14's work on a std::vector upgrade which doesn't have the really
> unfortunate unpredictable latency. The general idea is that a low latency
> std::vector would never expand its capacity automatically, instead it
> would return success + capacity approaching warning status. You then could
> schedule the construction of a new, bigger vector outside the hot path.

I find this example as unconvincing as Lawrence's original one. For one,
vector functions that grow the size typically return void. So you could just
turn that into bool or an enum and you'd be done.

For another, when you're in the hot path, the "capacity warning" status is
not actionable, so it's of little use. Instead, when you get out of the hot
path (or, better yet, before you get into it), you'd simply check
capacity(), see if it's yellow/red, and reserve. Or not even check, just
reserve( size() + <hot path max size requirement> ).

> so the idea was that expected<T, please_reallocate<T>> could be returned.

Sounds like the discussion took place in a pub. Not that there's anything
wrong with that. :-)

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