Subject: Re: string. vector vs string_view, span in reflection API
From: David Vandevoorde (daveed_at_[hidden])
Date: 2021-04-09 09:46:40
> On Apr 9, 2021, at 10:26 AM, Peter Dimov <pdimov_at_[hidden]> wrote:
> David Vandevoorde wrote:
>> One of the issues that arise is header dependenciesâ¦ do we really want to
>> require that <vector> and <string> be included for any code that does
>> something nontrivial with reflections? Maybe âyesâ, and maybe thatâll be less
>> of a concern with modules?
>> Meanwhile, our (Faisal & I) current implementation uses std::string_view (with
>> some assumptions about its internal structure) and a very simple
>> vector<info>-like class thatâs part of the <meta> header.
> That's another reason I prefer `char const*` - I don't find it elegant when
> compiler built-ins have to know about user-defined types such as `string_view`.
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.
(Our assumptions are that string_view is either a âstartâ pointer and a length (in any order) or a âstartâ pointer followed by an âendâ pointer.)
SG7 list run by email@example.com
Older Archives on Google Groups