-
Notifications
You must be signed in to change notification settings - Fork 103
Description
this cause warnings when porting std::regex
code to boost::regex
: warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
.
difference_type length(int sub = 0) const
https://github.com/boostorg/regex/blob/develop/include/boost/regex/v5/match_results.hpp#L100
https://en.cppreference.com/w/cpp/regex/match_results/length
string_type str(int sub = 0) const
https://github.com/boostorg/regex/blob/develop/include/boost/regex/v5/match_results.hpp#L164
https://en.cppreference.com/w/cpp/regex/match_results/str
const_reference operator[](int sub) const
https://github.com/boostorg/regex/blob/develop/include/boost/regex/v5/match_results.hpp#L199
https://en.cppreference.com/w/cpp/regex/match_results/operator_at
I think it's better to use size_type sub
as parameter as difference_type position(size_type sub = 0) const
:
https://github.com/boostorg/regex/blob/develop/include/boost/regex/v5/match_results.hpp#L131
https://en.cppreference.com/w/cpp/regex/match_results/position
and C-style cast inside these int sub
functions can be avoided:
- if(sub < (int)m_subs.size() && (sub > 0))
+ if(sub < m_subs.size())