C++ Logo

std-discussion

Advanced search

Re: objects with no lifetime for validation

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Sat, 27 May 2023 09:32:52 -0400
On Sat, May 27, 2023 at 2:23 AM Federico Kircheis via Std-Discussion
<std-discussion_at_[hidden]> wrote:
>
> On 27/05/2023 07.56, Jens Maurer wrote:
> >
> >
> > On 27/05/2023 07.36, Federico Kircheis via Std-Discussion wrote:
> >> Creating a view_data like
> >>
> >> struct data_view{
> >> span<string_view> otherdata;
> >> }
> >>
> >> wont work, as span<string_view> cannot point to vector<string>
> >
> > But a vector<string_view> can point to the individual elements
> > of a vector<string>.
>
> But this means creating a new vector.
> Plus duplicating classes.

There's no other way to have a bunch of string_views when that's not
what you started with. A string isn't a string_view, and no
reinterpret_cast gymnastics can even *theoretically* make that work.

Received on 2023-05-27 13:33:04