Huh, neat.

 

Does the proposal work for:

    VkInstance instance = 0;

    VkInstanceCreateInfo info {

        .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,

        .pApplicationInfo = (VkApplicationInfo[]) {{

            .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,

            .pApplicationName = "Hello World",

            .applicationVersion = VK_MAKE_VERSION(0, 1, 0),

            .pEngineName = "No Engine",

            .apiVersion = VK_API_VERSION_1_2

        };

    VkResult result = vkCreateInstance(&info, nullptr, &instance);

 

(pardon any mismatched brackets :\).

 

 

From: Zhihao Yuan <zy@miator.net>
Sent: Wednesday, May 12, 2021 3:48 PM
To: Charlie Barto <Charles.Barto@microsoft.com>
Cc: liaison@lists.isocpp.org
Subject: RE: [wg14/wg21 liaison] P2174 Status (and a tenuous offer to help)

 

On Wednesday, May 12, 2021 12:51 PM, Charlie Barto <Charles.Barto@microsoft.com> wrote:

 

extern “C” VkResult vkCreateInstance(const VkInstanceCreateInfo*, const VKAllocationCallbacks*, VkInstance*);

  

in C:

VkInstance instance = 0;

VkResult result = vkCreateInstance(&(VkInstanceCreateInfo){

                .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,

                .pApplicationInfo = &(VkApplicationInfo) {

.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,

                                .pApplicationName = “Hello World”,

                                .applicationVersion = VK_MAKE_VERSION(0, 1, 0),

                                .pEngineName = “No Engine”,

                                .apiVersion = VK_API_VERSION_1_2

                }}, NULL, &instance);

 

This usecase isn’t supported if the semantics are (T){…} === T{…}

 

The following is legal given the proposal:

 

    VkInstance instance = 0;

    VkResult result = vkCreateInstance((VkInstanceCreateInfo[]) {{

        .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,

        .pApplicationInfo = (VkApplicationInfo[]) {{

            .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,

            .pApplicationName = "Hello World",

            .applicationVersion = VK_MAKE_VERSION(0, 1, 0),

            .pEngineName = "No Engine",

            .apiVersion = VK_API_VERSION_1_2

        }}

    }}, nullptr, &instance);

 

Although it looks somewhat strange (GCC

forbids array-prvalue -> pointer conversion,

but the standard allows it).

 

https://godbolt.org/z/7n6rG8orY

 

Does that work for you?

 

--

Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
_______________________________________________