C++ Logo

SG7

Advanced search

Subject: Re: string. vector vs string_view, span in reflection API
From: Peter Dimov (pdimov_at_[hidden])
Date: 2021-04-09 09:56:37


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.


SG7 list run by sg7-owner@lists.isocpp.org

Older Archives on Google Groups