Output parameters in C++ are generally considered a code smell according to the core guidelines. Yet, we have such functions in the regular expressions library
template< class BidirIt,
class Alloc, class CharT, class Traits >
bool regex_match( BidirIt first, BidirIt last,
std::match_results<BidirIt,Alloc>& m,
const std::basic_regex<CharT,Traits>& e,
std::regex_constants::match_flag_type flags =
std::regex_constants::match_default );
in which m
is an output parameter. Is there a specific reason for breaking the core guidelines here and not simply returning the std::match_results
by value?