Date: Wed, 12 May 2021 20:11:49 +0000
That's true, but for that distinction to be useful the behavior would have to differ depending on if the _outer_ struct is a temporary, right?
-----Original Message-----
From: Jens Maurer <Jens.Maurer_at_[hidden]>
Sent: Wednesday, May 12, 2021 1:06 PM
To: liaison_at_[hidden]; Zhihao Yuan <zy_at_miator.net>
Cc: Charlie Barto <Charles.Barto_at_microsoft.com>
Subject: Re: [wg14/wg21 liaison] P2174 Status (and a tenuous offer to help)
On 12/05/2021 21.51, Charlie Barto via Liaison wrote:
> But in any case the before/after comparison
>
> extern “C” VkResult vkCreateInstance(const VkInstanceCreateInfo*,
> const VKAllocationCallbacks*, VkInstance*);
>
> in c++:
>
> VkApplicationInfo appinfo {
> .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 };
> VkInstanceCreateInfo createInfo {
> .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
> .pApplicationInfo = &appinfo, }; VkInstance instance =
> 0; auto result = vkCreateInstance(&createInfo, nullptr, &instance);
>
> 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);
I'd like to point out that this example is not about lifetime (full-expression vs. block), but about the fact that in C, compound literals are lvalues, so you can take their address.
Jens
-----Original Message-----
From: Jens Maurer <Jens.Maurer_at_[hidden]>
Sent: Wednesday, May 12, 2021 1:06 PM
To: liaison_at_[hidden]; Zhihao Yuan <zy_at_miator.net>
Cc: Charlie Barto <Charles.Barto_at_microsoft.com>
Subject: Re: [wg14/wg21 liaison] P2174 Status (and a tenuous offer to help)
On 12/05/2021 21.51, Charlie Barto via Liaison wrote:
> But in any case the before/after comparison
>
> extern “C” VkResult vkCreateInstance(const VkInstanceCreateInfo*,
> const VKAllocationCallbacks*, VkInstance*);
>
> in c++:
>
> VkApplicationInfo appinfo {
> .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 };
> VkInstanceCreateInfo createInfo {
> .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
> .pApplicationInfo = &appinfo, }; VkInstance instance =
> 0; auto result = vkCreateInstance(&createInfo, nullptr, &instance);
>
> 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);
I'd like to point out that this example is not about lifetime (full-expression vs. block), but about the fact that in C, compound literals are lvalues, so you can take their address.
Jens
Received on 2021-05-12 15:11:53