Date: Wed, 15 May 2024 09:43:21 +0100
On Wed, May 15, 2024 at 7:58 AM Jonathan Wakely wrote:
>
> Why would you want to hash the indeterminate padding
> bits between members anyway?
How about we add a new constexpr function to the standard library
called "std::zero_padding":
template<typename T> requires (!is_const_v< remove_reference_t<T> >)
constexpr T &&zero_padding(T &&obj, bool const skip_tail = false)
{
// Step 1: Zero out the padding bits inside integer types
// Step 2: Zero out the padding bytes between member variables
// Step 3: If 'skip_tail' is false, zero out the tail padding
// (must set to 'true' when used with 'no_unique_address')
}
With regard to Step 1, this is a throw back to the days when a 36-Bit
integer was a 32-Bit integer with 4 padding bits -- so probably
doesn't apply today.
The hash algorithm could hash "__datasizeof(T)" instead of
"sizeof(T)", which is why in the above function I give the option of
skipping the tail padding.
>
> Why would you want to hash the indeterminate padding
> bits between members anyway?
How about we add a new constexpr function to the standard library
called "std::zero_padding":
template<typename T> requires (!is_const_v< remove_reference_t<T> >)
constexpr T &&zero_padding(T &&obj, bool const skip_tail = false)
{
// Step 1: Zero out the padding bits inside integer types
// Step 2: Zero out the padding bytes between member variables
// Step 3: If 'skip_tail' is false, zero out the tail padding
// (must set to 'true' when used with 'no_unique_address')
}
With regard to Step 1, this is a throw back to the days when a 36-Bit
integer was a 32-Bit integer with 4 padding bits -- so probably
doesn't apply today.
The hash algorithm could hash "__datasizeof(T)" instead of
"sizeof(T)", which is why in the above function I give the option of
skipping the tail padding.
Received on 2024-05-15 08:43:33