boost-use-ranges¶
Detects calls to standard library iterator algorithms that could be replaced with a Boost ranges version instead.
Example¶
auto Iter1 = std::find(Items.begin(), Items.end(), 0);
auto AreSame = std::equal(Items1.cbegin(), Items1.cend(), std::begin(Items2),
std::end(Items2));
Transforms to:
auto Iter1 = boost::range::find(Items, 0);
auto AreSame = boost::range::equal(Items1, Items2);
Supported algorithms¶
Calls to the following std library algorithms are checked:
std::accumulatestd::adjacent_differencestd::adjacent_findstd::all_ofstd::any_ofstd::binary_searchstd::copy_backwardstd::copy_ifstd::copystd::count_ifstd::countstd::equal_rangestd::equalstd::fillstd::find_endstd::find_first_ofstd::find_if_notstd::find_ifstd::findstd::for_eachstd::generatestd::includesstd::iotastd::is_partitionedstd::is_permutationstd::is_sorted_untilstd::is_sortedstd::lexicographical_comparestd::lower_boundstd::make_heapstd::max_elementstd::mergestd::min_elementstd::mismatchstd::next_permutationstd::none_ofstd::partial_sumstd::partial_sort_copystd::partition_copystd::partition_pointstd::partitionstd::pop_heapstd::prev_permutationstd::push_heapstd::random_shufflestd::reducestd::remove_copy_ifstd::remove_copystd::remove_ifstd::removestd::replace_copy_ifstd::replace_copystd::replace_ifstd::replacestd::reverse_copystd::reversestd::searchstd::set_differencestd::set_intersectionstd::set_symmetric_differencestd::set_unionstd::sort_heapstd::sortstd::stable_partitionstd::stable_sortstd::transformstd::unique_copystd::uniquestd::upper_bound
The check will also look for the following functions from the
boost::algorithm namespace:
all_of_equalany_of_equalany_ofapply_permutationapply_reverse_permutationclamp_rangecopy_if_untilcopy_if_whilecopy_ifcopy_untilcopy_whilefind_backwardfind_if_backwardfind_if_not_backwardfind_if_notfind_not_backwardhex_lowerhexiotaall_ofis_decreasingis_increasingis_palindromeis_partitioned_untilis_partitionedis_permutationis_sorted_untilis_sortedis_strictly_decreasingis_strictly_increasingnone_of_equalnone_ofone_of_equalone_ofpartition_copypartition_pointreduceunhex
Reverse Iteration¶
If calls are made using reverse iterators on containers, The code will be
fixed using the boost::adaptors::reverse adaptor.
auto AreSame = std::equal(Items1.rbegin(), Items1.rend(),
std::crbegin(Items2), std::crend(Items2));
Transforms to:
auto AreSame = boost::range::equal(boost::adaptors::reverse(Items1),
boost::adaptors::reverse(Items2));
Options¶
- IncludeStyle¶
A string specifying which include-style is used,
llvmorgoogle. Default isllvm.
- IncludeBoostSystem¶
When
true, the Boost headers are included as system headers with angle brackets (#include <boost.hpp>), otherwise quotes are used (#include "boost.hpp").Default is
true.
- UseReversePipe¶
When
true, fixes which involve reverse ranges will use the pipe adaptor syntax instead of the function syntax.std::find(Items.rbegin(), Items.rend(), 0);
Transforms to:
boost::range::find(Items | boost::adaptors::reversed, 0);
Default is
false.