Date: Sun, 25 Jun 2023 18:35:30 +0300
On Sun, 25 Jun 2023 at 18:18, Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
>
>
> On Sunday, June 25, 2023, Edward Catmur wrote:
>>
>>
>> Frederick Virchanza Gotham wrote:
>>>
>>>
>>> then in the Release build it could become:
>>>
>>> #define g_obj ( g_optional_obj.value() )
>>
>>
>> How? Who controls this setting?
>
>
>
> #define __STL_OPTIONAL_SAFETY 0
> #include <optional>
>
> If you define the above macro, then for the current translation unit, 'g_obj' isn't checked to have a value.
>
> If you set it to 1, then it's checked and will throw std::bad_optional_access.
>
> If you set it to 2, then it's checked and it aborts.
So now you have reinvented how contracts work.
Std-Proposals <std-proposals_at_[hidden]> wrote:
>
>
> On Sunday, June 25, 2023, Edward Catmur wrote:
>>
>>
>> Frederick Virchanza Gotham wrote:
>>>
>>>
>>> then in the Release build it could become:
>>>
>>> #define g_obj ( g_optional_obj.value() )
>>
>>
>> How? Who controls this setting?
>
>
>
> #define __STL_OPTIONAL_SAFETY 0
> #include <optional>
>
> If you define the above macro, then for the current translation unit, 'g_obj' isn't checked to have a value.
>
> If you set it to 1, then it's checked and will throw std::bad_optional_access.
>
> If you set it to 2, then it's checked and it aborts.
So now you have reinvented how contracts work.
Received on 2023-06-25 15:35:44