Date: Sun, 16 Jul 2023 16:34:03 +0200
Il giorno dom 16 lug 2023 alle ore 15:13 Arthur O'Dwyer via
Std-Proposals <std-proposals_at_[hidden]> ha scritto:
>
> On Sun, Jul 16, 2023 at 8:48 AM Bjorn Reese via Std-Proposals <std-proposals_at_[hidden]> wrote:
>>
>> On 7/16/23 13:54, Frederick Virchanza Gotham via Std-Proposals wrote:
>>
>> > Emailed him yesterday, nothing back yet. For the time being I will
>> > re-write the code to accommodate lambdas-with-captures by using
>> > "std::function<void(void*)>" instead of function pointers. When I have
>>
>> Or you could simply write a mutex wrapper that locks in its constructor.
>
>
> Yes, that would be the "practical programming" approach. :) But it's true that NRVO-returning a `Wrapper` isn't quite the same thing as NRVO-returning a `std::mutex` itself.
> https://godbolt.org/z/6c54M176G
> With that approach, you can never afterward get the mutex "out" of the Wrapper in order to put it somewhere specific (such as into a `std::list<std::mutex>`).
std::mutex is not final, so you can inherit from it, and given are
adding just behavior, which gets triggered only on construction, and
no data, it seems to me it's totally safe to do.
See https://godbolt.org/z/dPT83MoGT
Fabio
Std-Proposals <std-proposals_at_[hidden]> ha scritto:
>
> On Sun, Jul 16, 2023 at 8:48 AM Bjorn Reese via Std-Proposals <std-proposals_at_[hidden]> wrote:
>>
>> On 7/16/23 13:54, Frederick Virchanza Gotham via Std-Proposals wrote:
>>
>> > Emailed him yesterday, nothing back yet. For the time being I will
>> > re-write the code to accommodate lambdas-with-captures by using
>> > "std::function<void(void*)>" instead of function pointers. When I have
>>
>> Or you could simply write a mutex wrapper that locks in its constructor.
>
>
> Yes, that would be the "practical programming" approach. :) But it's true that NRVO-returning a `Wrapper` isn't quite the same thing as NRVO-returning a `std::mutex` itself.
> https://godbolt.org/z/6c54M176G
> With that approach, you can never afterward get the mutex "out" of the Wrapper in order to put it somewhere specific (such as into a `std::list<std::mutex>`).
std::mutex is not final, so you can inherit from it, and given are
adding just behavior, which gets triggered only on construction, and
no data, it seems to me it's totally safe to do.
See https://godbolt.org/z/dPT83MoGT
Fabio
Received on 2023-07-16 14:34:16