C++ Logo

liaison

Advanced search

[wg14/wg21 liaison] P2174 Status (and a tenuous offer to help)

From: Charlie Barto <Charles.Barto_at_[hidden]>
Date: Wed, 12 May 2021 01:10:46 +0000
This email brought to you by fixing an ffmpeg wrapper that wouldn't compile on MSVC because we don't implement compound literals in c++ mode.

I've written a decent amount of wrapper code and/or Vulkan code that would have found compound literal support desirable. And from the looks of it the main problems with the proposal were that it didn't follow the C lifetime semantics and that it didn't really motivate itself (especially without the C lifetime semantics).

I might be willing to help with motivation (like helping write it) if there's still sufficient interest in continuing that paper. I suspect wording for the C lifetime version will be challenging. I can also see some of the safety issues as being challenges.

Note: my offer to help is only tenuously related to my job and employer, I won't really be able to dedicate "work time" toward this effort.


Sidenote:

It occurs to me that C style compound literals may allow a real "defer" construct: consider

template<void (*fn)()>
struct defer {
   ~defer() {
      fn();
   }
};

right now we need to use this as:

defer<some_function_call> _;

(we need to name the local variable)

with C style compound literals:

(defer<some_function_call>){};


... it's not super motivating since that syntax is .... not ideal, and because the "real" solution is probably to just use some kind of reflection.
Also you can kind of do it today with macro token pasting and source_location or __LINE__ and __FUNCTION__. Still, it's neat.

Received on 2021-05-11 20:10:50