C++ Logo

std-proposals

Advanced search

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

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Mon, 18 Dec 2023 16:29:26 +0000
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>) {}
    /* dst unaligned */ template<typename T> void _Relocate(void*,T
*) requires (!std::is_void_v<T>) {}
    /* both aligned */ template<typename T> void _Relocate(T *,T
*) requires (!std::is_void_v<T>) {}

    /* both unaligned */ template<typename T> void
_Relocate_n(void*,void*,std::size_t) {}
    /* src unaligned */ template<typename T> void _Relocate_n(T
*,void*,std::size_t) requires (!std::is_void_v<T>) {}
    /* dst unaligned */ template<typename T> void _Relocate_n(void*,T
  *,std::size_t) requires (!std::is_void_v<T>) {}
    /* both aligned */ template<typename T> void _Relocate_n(T *,T
  *,std::size_t) requires (!std::is_void_v<T>) {}

This would really make the micro-optimisers happy.

Received on 2023-12-18 16:29:20