Subject: Re: string. vector vs string_view, span in reflection API
From: David Vandevoorde (daveed_at_[hidden])
Date: 2021-04-09 09:50:06
> On Apr 9, 2021, at 10:28 AM, Matus Chochlik via SG7 <sg7_at_[hidden]> wrote:
> On Fri, Apr 9, 2021 at 4:26 PM Peter Dimov via SG7 <sg7_at_[hidden] <mailto:sg7_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`.
> But I don't think it is necessary for the built-ins to know about string_view, the builtins are usually wrapped into something that can take a `const char[N]` from the built-in and turn it into a string view.
Yes, we could go with the public API of std::string_view, but we chose to construct them directly for improved efficiency and to avoid having the constant-evaluator call back into the front end proper (although eventually that will be unavoidable for some meta-APIs).
SG7 list run by email@example.com
Older Archives on Google Groups