|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2019-11-27 00:24:38
Gavin Lambert wrote:
> On 27/11/2019 06:46, Peter Dimov wrote:
> > Vinnie Falco wrote:
> >
> >> In which use-cases do you anticipate the need for a constexpr
> >> static_string?
> >
> > When manipulating strings at compile time? Such as s1 += s2?
>
> Wouldn't that use case be better served with an immutable string and
> operator+?
Not in general.
constexpr string_view f( int x );
constexpr auto g( int n )
{
fixed_string<512> s;
for( int i = 0; i < n; ++i )
{
s += f( i );
}
return s;
}
You can rewrite this specific example using recursion but in general, it'd
be painful and unreadable.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk