boostorg / algorithm

Boost.org algorithm module
http://boost.org/libs/algorithm
Boost Software License 1.0
112 stars 105 forks source link

Fix -Wdeprecated-copy warnings in string algorithms #88

Closed apolukhin closed 2 years ago

apolukhin commented 2 years ago

Compiling algorithm/string/test with command ../../../../b2 cxxstd=2a "cxxflags=-Werror=deprecated-copy" toolset=gcc-9 -j4 without the patch produces warnings like the following:

split_test.cpp:193:14: error: implicitly-declared ‘boost::algorithm::find_iterator<__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> > >& boost::algorithm::find_iterator<__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> > >::operator=(const boost::algorithm::find_iterator<__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> > >&)’ is deprecated [-Werror=deprecated-copy]
  193 |     fiter2 = fiter;
      |              ^~~~~
mclow commented 2 years ago

When I run b2 cxxstd=2a "cxxflags=-Werror=deprecated" using clang, I get similar errors on both find_iterator and split_iterator

In file included from split_test.cpp:12:
In file included from ../../../../boost/algorithm/string/split.hpp:16:
In file included from ../../../../boost/algorithm/string/iter_find.hpp:27:
../../../../boost/algorithm/string/find_iterator.hpp:243:13: error: definition of implicit copy assignment operator for 'split_iterator<std::__1::__wrap_iter<char *> >' is deprecated because it has a user-declared copy constructor [-Werror,-Wdeprecated]
            split_iterator( const split_iterator& Other ) :
            ^
split_test.cpp:209:12: note: in implicit copy assignment operator for 'boost::algorithm::split_iterator<std::__1::__wrap_iter<char *> >' first required here
    siter2 = siter;
           ^
apolukhin commented 2 years ago

"cxxflags=-Werror=deprecated" gives way more warnings that I was planning to fix in this PR.

Tested the patch on clang via./b2 libs/algorithm/string/test/ cxxstd=2a,03,11,17,14 "cxxflags=-Werror=deprecated-copy" toolset=clang-13 -j4 -a. Works fine

mclow commented 2 years ago

LGTM. Thanks!