forked from Alepha/Alepha
Start moving towards the alignment solution>
Some of this needs to be branched out.
This commit is contained in:
@ -221,11 +221,17 @@ namespace Alepha::Hydrogen ::detail:: Blob_m
|
||||
* inside a large single physical backing. This helps maintain zero-copy semantics.
|
||||
*
|
||||
* @param amount The amount of data to carve off.
|
||||
* @return A new `Blob` object referring to the same physical data, scoped to `amount` bytes.
|
||||
* @param alignment The size alignment that the new base should be at (the extra padding is
|
||||
* considered part of the resulting `Blob`).
|
||||
* @return A new `Blob` object referring to the same physical data, scoped to `amount` bytes (with
|
||||
* possible extra space, due to alignment).
|
||||
*/
|
||||
Blob
|
||||
carveHead( const std::size_t amount )
|
||||
carveHead( const std::size_t unalignedAmount, Alignment alignment= Alignment{ 1 } )
|
||||
{
|
||||
assert( std::popcount( alignment.amt ) == 1 );
|
||||
// TODO: Consider arithmetic overflow, here.
|
||||
const std::size_t amount= alignTo( ( reinterpret_cast< std::uintptr_t >( data() ) % alignment.amt ) + unalignedAmount, alignment );
|
||||
if( amount > size() ) throw DataCarveTooLargeError( data(), amount, size() );
|
||||
if( not storage )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user