Date: Wed, 04 Sep 2024 13:45:25 +0200
On Tuesday 3 September 2024 00:55:45 CEST Sebastian Wittmeier via Std-
Proposals wrote:
> In general a container can do
>
> if constexpr (std::is_same_v<T, int>)
> ...
>
> Is this true, if the underlying type is int and T is a subtype?
A concrete but very ill-advised example:
std::optional<T> where T is a floating-point type can decide it only stores
normalised results and use the negative zero representation as the marker for
the disengaged state. That would make sizeof(std::optional<T>) == sizeof(T).
But if T is a struct wrapping a floating-point value and is thus itself not
std::is_floating_point_v<T>, std::optional would use a separate representation.
That means the two std::optional are not isomorphic.
Proposals wrote:
> In general a container can do
>
> if constexpr (std::is_same_v<T, int>)
> ...
>
> Is this true, if the underlying type is int and T is a subtype?
A concrete but very ill-advised example:
std::optional<T> where T is a floating-point type can decide it only stores
normalised results and use the negative zero representation as the marker for
the disengaged state. That would make sizeof(std::optional<T>) == sizeof(T).
But if T is a struct wrapping a floating-point value and is thus itself not
std::is_floating_point_v<T>, std::optional would use a separate representation.
That means the two std::optional are not isomorphic.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel DCAI Platform & System Engineering
Received on 2024-09-04 11:45:38