C++ Logo

std-discussion

Advanced search

Re: propagate_const for array-like types

From: Daniel Krügler <daniel.kruegler_at_[hidden]>
Date: Fri, 25 Nov 2022 06:55:07 +0100
Am Fr., 25. Nov. 2022 um 06:48 Uhr schrieb Wilhelm Meier via
Std-Discussion <std-discussion_at_[hidden]>:
>
> Hello all,
>
> std::experimental::propagate_const is a wrapper to propagate const to
> the pointer-to object for pointer-like types (e.g. std::unique_ptr<T>).
>
> But it lacks of a specialization for array-like types (e.g.
> std::unique_ptr<T[]>. Is that intentional or are there any other obstacles?

I can't tell you about obstacles, but the wording is intentional this
way, since [propagate_const.requirements] says
(https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/n4840.html#propagate_const.requirements)
in paragraph 2 (emphasis mine):

"If *T is an array type*, reference type, pointer to function type or
pointer to (possibly cv-qualified) void, then *the program is
ill-formed*."

- Daniel

Received on 2022-11-25 05:55:19