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?

 

Or a container could even change member variable types and sizes depending on the template parameter.

 

What should a compiler automatically do then?

 

-----Ursprüngliche Nachricht-----
Von: Karafiát, László via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Di 03.09.2024 00:40
Betreff: Re: [std-proposals] Fwd: Standardised Type Punning API for Wrapper Types
An: Sebastian Wittmeier via Std-Proposals <std-proposals@lists.isocpp.org>;
CC: Karafiát, László <laszlo@karafiat.name>;
I thought the vector would be type of sub-type, but the elements are
'automatically' super-type on demand i.e. when the compiler detects a
chance for this (built-in) cast. e.g. the compiler cwould automatically
generate some (internal) templates for the super- and sub-types as
needed. There are not many cases - the number of built-in scalar types
(here the super-types) are limited.


*cwould: sorry Mr. Shakespaeare - it is rather late here now.. ( CET :)