C++ Logo

sg7

Advanced search

Re: [SG7] Update: P1240R2 — Scalable Reflection

From: Barry Revzin <barry.revzin_at_[hidden]>
Date: Tue, 18 Jan 2022 12:49:10 -0600
On Tue, Jan 18, 2022 at 12:29 PM Peter Dimov via SG7 <sg7_at_[hidden]>
wrote:

> > But on the other hand, if you have a `char const*`, it's trivial to
> obtain a
> > string_view from it, whereas the reverse... isn't.
>
> <source>:9:27: error: 'std::basic_string_view<char>' is not a valid type
> for a template non-type parameter because it is not structural
> 9 | template<std::string_view sv> consteval auto to_charp()
> | ^~
>
> Yeah :-(


This is actually a good reason to return string and vector<info> instead of
string_view/char const* and span<info>. The containers will be usable as
non-type template parameters (eventually), but the views will never be, and
while char const* could be it's also not as usable.

Barry

Received on 2022-01-18 18:49:24