Boost logo

Boost :

Subject: [boost] Discovering and handling missing override keyword in project conversion
From: James E. King, III (jking_at_[hidden])
Date: 2017-12-06 22:15:53


I'm in the middle of converting a large project from C++03 to C++14, and of
course crossing the C++11 gap, I want identify all of the places where the
override keyword should be used but is not, and add it.

When I turned on -Wsuggest-override in gcc-7.2 I got a fair number of
warnings from boost code, for example:

...boost/program_options/value_semantic.hpp:304:14: error: ‘bool
boost::program_options::typed_value<T, charT>::is_composing() const [with T
= std::basic_string<char>; charT = char]’ can be marked override
[-Werror=suggest-override]
         bool is_composing() const { return m_composing; }
              ^~~~~~~~~~~~
...boost/program_options/value_semantic.hpp:306:18: error: ‘unsigned int
boost::program_options::typed_value<T, charT>::min_tokens() const [with T =
std::basic_string<char>; charT = char]’ can be marked override
[-Werror=suggest-override]
         unsigned min_tokens() const
                  ^~~~~~~~~~
...boost/program_options/value_semantic.hpp:315:18: error: ‘unsigned int
boost::program_options::typed_value<T, charT>::max_tokens() const [with T =
std::basic_string<char>; charT = char]’ can be marked override
[-Werror=suggest-override]
         unsigned max_tokens() const {
                  ^~~~~~~~~~
...boost/program_options/value_semantic.hpp:325:14: error: ‘bool
boost::program_options::typed_value<T, charT>::is_required() const [with T
= std::basic_string<char>; charT = char]’ can be marked override
[-Werror=suggest-override]
         bool is_required() const { return m_required; }
              ^~~~~~~~~~~

(There were others - this is just a small sample)

This is probably not the first time this has been brought up, but there is
no BOOST_OVERRIDE (or BOOST_FINAL, for that matter) definition in
Boost.Config that would allow Boost itself to be compatible with C++03 or
C++11 cleanly relative to this language feature. I found a number of posts
about this issue elsewhere. Has this issue been discussed here before?

I could spend some time adding this to Boost.Config and then making boost
compile cleanly with cxxstd=03,11 toolset=gcc-7
cxxflags="-Wsuggest-override", as it would help support a more complete
conversion to the new language level for projects, and it would enable
existing projects to turn on the warning to improve their code, as well as
improve Boost.

Thoughts?

- Jim


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk