C++ Logo

sg7

Advanced search

Re: [SG7] Update: P1240R2 — Scalable Reflection

From: Peter Dimov <pdimov_at_[hidden]>
Date: Tue, 18 Jan 2022 21:16:22 +0200
Daveed Vandevoorde wrote:
> > On Jan 18, 2022, at 1:46 PM, Peter Dimov <pdimov_at_[hidden]> wrote:
> >
> > Daveed Vandevoorde wrote:
> >> How about specifying that all string_view results from reflection
> >> functions (there aren’t that many) have a null-terminated data()?
> >> E,g,:
> >>
> >> auto len = std::strlen(name_of(^S).data()); // Okay and as
> >> intuitively expected.
> >
> > Works for me, with the minor addition of `constexpr` before `auto len`.
>
> Can you elaborate on the minor addition? Are you just asking for std::strlen to
> be guaranteed evaluatable at compile time for strings?

For the specific strings obtained by some_reflection_function().data(), yes.

constexpr auto len = std::strlen(name_of(^S).data());

Received on 2022-01-18 19:16:24