Date: Sat, 30 Nov 2024 12:46:55 +0100
"What usage examples do you have for the typeless_memory ...."
The biggest hole that we can currently have is that You can dynamically
allocate memory in consteval but You can not use in class buffer memory for
storing non trivial types. And for trivial types You have to initialize
such buffer memory even when from owning type view is "unused".
examples are any custom types with in class buffer memory for example like
static vectors, partially buffered vectors (to N elems)
AFIR gnu stdc++ for using std::string in constexpr uses internally out of
standard accessing non active union member in cosntexpr.
On Sat, Nov 30, 2024 at 11:45 AM Sebastian Wittmeier via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> The current typeless memory is either
>
> - std::byte, char, unsigned char
>
>
>
> As compile-time evaluation tries to avoid UB nearly completely and also
> tries to not use any implementation-defined features, there is less room
> for low-level inspection or modification.
>
>
>
> There is also constexpr std::bit_cast
>
>
>
> What usage examples do you have for the typeless_memory, which are not
> implementation-defined, allow the compiler to check and avoid UB (which
> e.g. entails an understanding of object lifetimes, types and memory
> locations) and which cannot be solved with the current tools in the
> standard library?
>
>
>
>
> -----Ursprüngliche Nachricht-----
> *Von:* James via Std-Proposals <std-proposals_at_[hidden]>
> *Gesendet:* Sa 30.11.2024 10:56
> *Betreff:* [std-proposals] std::typeless_memory (type punning)
> *An:* std-proposals_at_[hidden];
> *CC:* James <james.business.84_at_[hidden]>;
> Currently you can do whatever you want at runtime when it comes to type
> punning. Sure, all of them might not be safe, but you have some ways to do
> it safely. However in compile time (as far as I know) there is no way to
> achieve type punning.
>
> So I'd like to see this type, in standard library
> https://godbolt.org/z/1dEjYW1hW
>
> It's only purpose is to allow treating some underlying memory as whatever
> type you want in compile time without using extra memory. It would also
> provide a shortcut for runtime usage
> Currently you can't achieve that due to placement new and reinterpret_cast
> not being usable in compile time context
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
The biggest hole that we can currently have is that You can dynamically
allocate memory in consteval but You can not use in class buffer memory for
storing non trivial types. And for trivial types You have to initialize
such buffer memory even when from owning type view is "unused".
examples are any custom types with in class buffer memory for example like
static vectors, partially buffered vectors (to N elems)
AFIR gnu stdc++ for using std::string in constexpr uses internally out of
standard accessing non active union member in cosntexpr.
On Sat, Nov 30, 2024 at 11:45 AM Sebastian Wittmeier via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> The current typeless memory is either
>
> - std::byte, char, unsigned char
>
>
>
> As compile-time evaluation tries to avoid UB nearly completely and also
> tries to not use any implementation-defined features, there is less room
> for low-level inspection or modification.
>
>
>
> There is also constexpr std::bit_cast
>
>
>
> What usage examples do you have for the typeless_memory, which are not
> implementation-defined, allow the compiler to check and avoid UB (which
> e.g. entails an understanding of object lifetimes, types and memory
> locations) and which cannot be solved with the current tools in the
> standard library?
>
>
>
>
> -----Ursprüngliche Nachricht-----
> *Von:* James via Std-Proposals <std-proposals_at_[hidden]>
> *Gesendet:* Sa 30.11.2024 10:56
> *Betreff:* [std-proposals] std::typeless_memory (type punning)
> *An:* std-proposals_at_[hidden];
> *CC:* James <james.business.84_at_[hidden]>;
> Currently you can do whatever you want at runtime when it comes to type
> punning. Sure, all of them might not be safe, but you have some ways to do
> it safely. However in compile time (as far as I know) there is no way to
> achieve type punning.
>
> So I'd like to see this type, in standard library
> https://godbolt.org/z/1dEjYW1hW
>
> It's only purpose is to allow treating some underlying memory as whatever
> type you want in compile time without using extra memory. It would also
> provide a shortcut for runtime usage
> Currently you can't achieve that due to placement new and reinterpret_cast
> not being usable in compile time context
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2024-11-30 11:47:11