C++ Logo

sg7

Advanced search

Re: [SG7] string. vector vs string_view, span in reflection API

From: Peter Dimov <pdimov_at_[hidden]>
Date: Fri, 9 Apr 2021 17:56:37 +0300
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. 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.

Received on 2021-04-09 09:56:40