|
Boost : |
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2022-05-27 15:31:27
On 5/27/22 16:18, Mateusz Loskot via Boost wrote:
> On Fri, 27 May 2022 at 13:01, Andrey Semashev via Boost wrote:
>> On 5/27/22 05:14, Emil Dotchevski via Boost wrote:
>>> On Sun, May 22, 2022 at 3:35 AM Andrey Semashev via Boost wrote:
>>>> I'd replace 0 with NULL. If the compiler keeps complaining report a
>>>> compiler bug and suppress the warning with a pragma.
>>>
>>> I'm all for disabling useless warnings, but then you can leave 0 in the
>>> code and not bother with NULL. What are you, a C programmer? :)
>>
>> It *is* a useless warning. The code with NULL is explicit enough and
>> portable, so what is this warning about? That the code is not
>> C++11-only? I know that, and it's not up to the compiler to tell me that.
>
> Even if you compile with -std=c++11 ?
Yes. Because you may be including third-party code that is
C++03-compatible. Or C. Which is not at all uncommon.
I seriously don't understand this strive to pull the world into C++XY
and set the rest on fire. Newer C++ versions extend your toolbox and
make your life easier (in most cases), and that is great and very
useful. But the fact that you can enable newer C++ version in your
compiler doesn't render the code that was written before it invalid or
bad or somehow else second-grade. Written code doesn't rewrite itself,
especially when that code works and reads perfectly well.
Personally, the main project I'm working on outside Boost is C++17. But
this project uses a lot of third-party libraries written in C and C++,
some of them C++03, with NULL, auto_ptr and other remnants of the old in
public headers. And I'm really pissed by compilers when they litter
output with warnings about stuff being deprecated or "bad style"
according to whatever guide is popular today among compiler vendors,
while the code in question actually works as expected. And how am I
supposed to act on these warnings? Do I have to rewrite the working
libraries according to the new style, retest everything, push the
changes upstream? What if the upstream project is still interested in
legacy systems that only have access to C++03? Is the amount of effort
it would take even considered when these warnings are implemented?
So my opinion is this: If you can use C++11 or newer and there are
tangible benefits to it - you are very welcome to do so. But don't force
the world to do the same. This goes for Boost and beyond. And warnings
about "bad style" are only useful to purists who want their code base
"pure C++11" for whatever imaginary reason; they are useless at best and
harmful at worst for all normal people.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk