C++ Logo

std-proposals

Advanced search

Re: [std-proposals] [[packed]] std::unaligned

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 18 Dec 2023 13:54:57 -0300
On Monday, 18 December 2023 13:29:26 -03 Frederick Virchanza Gotham via Std-
Proposals wrote:
> On Mon, Dec 18, 2023 at 1:00 PM Thiago Macieira wrote:
> > That's hyper- and micro-optimisation.
>
> You beat me to it. Maybe the functions '_Relocate' and '_Relocate_n'
> (or 'std::relocate' and 'std::relocate_n') should have four forms as
> follows:
>
> #include <cstddef> // size_t
> #include <type_traits> // is_void
>
> /* both unaligned */ template<typename T> void _Relocate(void*,void*) {}
> /* src unaligned */ template<typename T> void _Relocate(T
> *,void*) requires (!std::is_void_v<T>) {}

There shouldn't be unaligned versions. The parameters should be plain T
pointers.

T may be std::unaligned<X>, but that's a special-casing scenario and shouldn't
require any code on the part of the user: std::unaligned's template relocator
(however that is implemented) should just DTRT.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-12-18 16:55:00