C++ Logo

std-discussion

Advanced search

Re: format_to (a char array) easy to misuse

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Thu, 6 Oct 2022 08:54:39 +0100
On Thu, 6 Oct 2022 at 07:28, Olaf van der Spek <ml_at_[hidden]> wrote:

> On Tue, Oct 4, 2022 at 9:24 PM Edward Catmur <ecatmur_at_[hidden]>
> wrote:
> > It would probably make sense to warn on / deprecate
> `std::format_to(T(&)[N], ...)`. I think compilers should be able to do that
> without any change to the Standard.
>
> It's not just C arrays. If I pass std::array::begin() or data() or
> std::array::begin() or data() the same thing happens.
>

That's obviously incorrect, though (passing in the beginning of a finite
range) so it's less of a concern. Passing an array by reference looks like
it should work (and does work elsewhere).

Received on 2022-10-06 07:54:51