C++ Logo

std-proposals

Advanced search

Re: Allow [[deprecated]] on call site to disable deprecated warning

From: Dominic Fandrey <isocpp.id_at_[hidden]>
Date: Thu, 4 Feb 2021 08:54:54 +0100
All of these have drawbacks that explicitly stating my intent in the
source doesn't. I like the suggestion with the linter pass best so far
and I'm thinking about proposing something like this to our devops team.

Kudos to you for forging the quote.

On 28/01/2021 20:28, codusnocturnus via Std-Proposals wrote:
> [ ] you have thought of existing ways to solve your problem before suggesting changes to the language, including simple ones
>
> Sent from ProtonMail Mobile
>
> On Thu, Jan 28, 2021 at 10:40 AM, Dominic Fandrey via Std-Proposals <std-proposals_at_[hidden]> wrote:
>
>> On 28/01/2021 14:27, codusnocturnus via Std-Proposals wrote:
>>> The major compilers provide a way to suppress specific warnings.
>>
>> [ X] you have read the mail you replied to
>>
>>> https://godbolt.org/z/YaEv5M
>>>
>>>
>>>
>>> Sent with ProtonMail Secure Email.
>>>
>>> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>>> On Thursday, January 28, 2021 4:05 AM, Dominic Fandrey via Std-Proposals <std-proposals_at_[hidden]> wrote:
>>>
>>>> I recently ran into this issue:
>>>>
>>>> 1. Marked a set of legacy methods [[deprecated]]
>>>> 2. Unit tests no longer compile (we run -Wall -Werror of course)
>>>>
>>>> Of course I don't want to get rid of the unit tests before I get rid of the
>>>> functions. So I was faced with two choices:
>>>>
>>>> 3. Create #ifdef #pragma soup for all 3 compilers that we use
>>>> 4. Remove [[deprecated]]
>>>>
>>>> The #ifdef #pragma soup needs to be updated every time a compiler is added,
>>>> and it bloats the code and makes unit tests more difficult to read. So I
>>>> went for option 2. As long as I cannot ignore [[deprecated]] in a portable
>>>> manner I cannot use it.
>>>>
>>>> So my suggestion is:
>>>>
>>>>
>>>> [[deprecated("use: std::optional<std::size_t> size()")]]int size(std::size_t & size);
>>>>
>>>>
>>>>
>>>> bool test_size() {
>>>> std::size_t s{0};
>>>> return 0 == [[deprecated]]size(s) && s != 0;
>>>> }
>>>>
>>>>
>>>> Regards
>> --
>> Std-Proposals mailing list
>> Std-Proposals_at_[hidden]
>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>

Received on 2021-02-04 01:54:59