Subject: Re: string. vector vs string_view, span in reflection API
From: David Vandevoorde (daveed_at_[hidden])
Date: 2021-04-09 09:59:58
> On Apr 9, 2021, at 10:56 AM, Peter Dimov <pdimov_at_[hidden]> wrote:
> David Vandevoorde wrote:
>> Implementation-wise itâs not as elegant, but I suspect programmers might like
>> it better on average. Itâs also potentially a performance win, because at the
>> time we create the string_view, we know the bounds of the array. If we
>> return it as a char const*, youâd have to recover that.
> Bounds-wise `char const*` and string_view are basically equivalent because
> in either case the length is a constant expression.
When I said âperformance winâ, I meant âcompile-time performanceâ ;-)
I.e., we can avoid evaluation loop at compile-time. The win might not be significant (or it might even be a slight loss) if the length is computed using an intrinsic though.
> I did get a request for
> char const though, instead of char const*. I'm reluctant to switch to that
> because I'm afraid it may introduce the same problems __func__ had.
SG7 list run by email@example.com
Older Archives on Google Groups