Would it?

The sub-types would be different types in the type system, and so would be the templated container classes, wouldn't they?

 

Or would the proposal <Scalar Inheritance> use the scalar type for templates?
 

-----Ursprüngliche Nachricht-----
Von: Karafiát, László <laszlo@karafiat.name>
Gesendet: Mo 02.09.2024 18:43
Betreff: Re: [std-proposals] Fwd: Standardised Type Punning API for Wrapper Types
An: std-proposals@lists.isocpp.org;
CC: Sebastian Wittmeier <wittmeier@projectalpha.org>;
Hi,

my proposal <Scalar Inheritance> would allow sub-typing (instead of
wrapping) scalar types. Would that be not a clearer and better solution?

László

On 2024-09-02 17:07, Sebastian Wittmeier via Std-Proposals wrote:
> How would you know that the container specialization is different?
>
> Or in other words they are always different as it is a template.
>
> At least each container would have to support such a facility to remove
> the type by itself. Otherwise the implementation details could hide
> incompatibilities.
>
> std::vector could support a move_to member function:
>
> std::vector<my_distance_type> d1;
>
> // creates a new d2 with new metadata, but keeps the convertible actual
> data without copying
>
> // d1 is empty afterwards
>
> std::vector<double> d2 = d1.move_to<double>();
>
>