namespace re_detail{
-template <class charT>
class named_subexpressions;
}
typedef typename re_detail::regex_iterator_traits<
BidiIterator>::value_type char_type;
typedef std::basic_string<char_type> string_type;
- typedef re_detail::named_subexpressions_base<char_type> named_sub_type;
+ typedef re_detail::named_subexpressions named_sub_type;
// construct/copy/destroy:
explicit match_results(const Allocator& a = Allocator())
//
const_reference named_subexpression(const char_type* i, const char_type* j) const
{
+ //
+ // Scan for the leftmost *matched* subexpression with the specified named:
+ //
if(m_is_singular)
raise_logic_error();
- int index = m_named_subs->get_id(i, j);
- return index > 0 ? (*this)[index] : m_null;
+ re_detail::named_subexpressions::range_type r = m_named_subs->equal_range(i, j);
+ while((r.first != r.second) && ((*this)[r.first->index].matched == false))
+ ++r.first;
+ return r.first != r.second ? (*this)[r.first->index] : m_null;
}
template <class charT>
const_reference named_subexpression(const charT* i, const charT* j) const
}
int named_subexpression_index(const char_type* i, const char_type* j) const
{
+ //
+ // Scan for the leftmost *matched* subexpression with the specified named.
+ // If none found then return the leftmost expression with that name,
+ // otherwise an invalid index:
+ //
if(m_is_singular)
raise_logic_error();
- int index = m_named_subs->get_id(i, j);
- return index > 0 ? index : -20;
+ re_detail::named_subexpressions::range_type s, r;
+ s = r = m_named_subs->equal_range(i, j);
+ while((r.first != r.second) && ((*this)[r.first->index].matched == false))
+ ++r.first;
+ if(r.first == r.second)
+ r = s;
+ return r.first != r.second ? r.first->index : -20;
}
template <class charT>
int named_subexpression_index(const charT* i, const charT* j) const
std::swap(m_subs, that.m_subs);
std::swap(m_named_subs, that.m_named_subs);
std::swap(m_last_closed_paren, that.m_last_closed_paren);
- std::swap(m_is_singular, that.m_is_singular);
if(m_is_singular)
{
if(!that.m_is_singular)
std::swap(m_base, that.m_base);
std::swap(m_null, that.m_null);
}
+ std::swap(m_is_singular, that.m_is_singular);
}
bool operator==(const match_results& that)const
{
void BOOST_REGEX_CALL set_second(BidiIterator i, size_type pos, bool m = true, bool escape_k = false)
{
if(pos)
- m_last_closed_paren = pos;
+ m_last_closed_paren = static_cast<int>(pos);
pos += 2;
BOOST_ASSERT(m_subs.size() > pos);
m_subs[pos].second = i;