C++ Logo

std-proposals

Advanced search

Re: [std-proposals] [[packed]] std::unaligned (Paper Attached)

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Thu, 4 Jan 2024 10:38:31 +0000
On Mon, Dec 25, 2023 at 11:26 AM Frederick Virchanza Gotham
<cauldwell.thomas_at_[hidden]> wrote:
>
> I've added a new paragraph to the paper to say that a pre-existing
> buffer can be treated as an unaligned<T>.
>
> Draft No. 3 is attached as a PDF file and can also be downloaded from:
>
> http://virjacode.com/papers/unaligned_latest.pdf


I'm now up to Draft No. 4:

    http://www.virjacode.com/papers/unaligned_latest.pdf

and also it's attached to this email as a PDF file.

I realised that if the programmer were to provide a custom relocator
for any given type, for example:

    std::unaligned< std::string, MyRelocatorForString > my_variable;

then this would complicate the use of:

    typedef<packed> MyStruct MyPackedStruct;

because the following unpacked struct:

    struct MyStruct {
        std::string str;
    };

would become:

    struct MyPackedStruct {
        std::unaligned<std::string> str;
    };

The problem here is that we have 'std::unaligned<std::string>' when
really we want 'std::unaligned< std::string, MyRelocatorForString >'.

To get around this problem, I've changed the design of
'std::unaligned' so that it only takes one template parameter:

    template<typename T>
    class unaligned { . . . };

And so now the user provides custom relocators by defining a struct in
the global namespace "::_Relocator_Custom" (see page 5 of my paper).

FILE ATTACHED: unaligned_draft04.pdf (4 January 2024)

Received on 2024-01-04 10:38:44