C++ Logo

SG7

Advanced search

Subject: Re: string. vector vs string_view, span in reflection API
From: Peter Dimov (pdimov_at_[hidden])
Date: 2021-04-09 07:26:01


Matus Chochlik wrote:
> Hi,
>
> IIUC the current plan is to use `string` and `vector<meta::info>` in the
> reflection API (both of which require consteval dynamic allocation). Is this
> correct and if so, was there some reason for not using `string_view` and
> `span<meta::info>` instead? The returned metadata is always static, so
> mutable containers look like overkill.

I would go even further and argue in favor of returning char const*. You
can construct a string_view from that but not vice versa.

vector<info> can't be replaced with span<info> though because it's
often built dynamically (e.g. if the contents are filtered with a predicate.)


SG7 list run by sg7-owner@lists.isocpp.org

Older Archives on Google Groups