Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayProxy with designated initializers #1909

Open
barcharcraz opened this issue Jun 25, 2024 · 0 comments
Open

ArrayProxy with designated initializers #1909

barcharcraz opened this issue Jun 25, 2024 · 0 comments

Comments

@barcharcraz
Copy link

barcharcraz commented Jun 25, 2024

It seems like it should be possible for vulkan-hpp to generate structure types that look approximately like:

struct WhateverInfo {
  ...
   union {
     struct {
        uint32_t whateverThingsCount;
        whateverThing* pWhateverThings;
     };
     ArrayProxyNoTemporaries<whateverThing> whateverThings;
   };
};

or even just an option to generate ArrayProxy data members instead of the count and pointer members.

Is there interest in this?

Note: this relies on the commonly implemented extension where reading non-active union members is allowed. This isn't that relevant because you're using this extension across translation units (one of which is likely C), and vulkan-hpp is already fudging things in this area.

Edit: actually, reading the non-active union member is defined behavior, ArrayProxy and the anonymous struct have a common-initial-sequence. And casting this to the "normal" definition and reading from it is also (probably?) defined behavior because the two types should be layout-compatible (although the rules for layout compatibility between a struct and a union like this don't seem that well specified).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant