Modify

Ticket #7237 (closed Feature Requests: fixed)

Opened 21 months ago

Last modified 15 months ago

Make sub_match a proper range

Reported by: zeratul976@… Owned by: eric_niebler
Milestone: To Be Determined Component: xpressive
Version: Boost 1.51.0 Severity: Problem
Keywords: Cc:

Description

boost::xpressive::sub_match comes close to being a proper Range, but it's not quite. It has a nested type named 'iterator', but not one named 'const_iterator', and it lacks begin() and end() functions.

It should be very straightforward to add these missing bits and make it a proper range. Alternately, it could derive from boost::iterator_range<BidiIter?> rather than std::pair<BidiIter?, BidiIter?>.

Attachments

Change History

comment:1 Changed 20 months ago by eric_niebler

  • Status changed from new to assigned

xpressive's sub_match is closely modeled on std::sub_match, which doesn't have the members you refer to. But xpressive doesn't slavishly follow the standard, and what you suggest is reasonable. I would prefer to non-intrusively make sub_match a valid range by hooking Boost.Range's customization points.

But would sub_match's const_iterator be a typedef for iterator, or would it const-ify the iterator (if necessary)? And do I need rbegin/rend, cbegin/cend, crbegin/crend and the associated typedefs, too? Sheesh! Opinions?

comment:2 Changed 20 months ago by zeratul976@…

xpressive's sub_match is closely modeled on std::sub_match, which doesn't have the members you refer to

Right, because ranges haven't been fully standardized. I expect that when they are, care will be taken to make things like std::sub_match be a Range.

I would prefer to non-intrusively make sub_match a valid range by hooking Boost.Range's customization points.

That's reasonable.

would sub_match's const_iterator be a typedef for iterator, or would it const-ify the iterator (if necessary)?

const_iterator should be the type returned when calling begin() on a 'const sub_match', so the answer depends on whether you think it should be allowed to modify the string through a 'const sub_match'. I have no strong feelings either way.

And do I need rbegin/rend, cbegin/cend, crbegin/crend and the associated typedefs, too?

No. Those members are required by the standard Container concept, which is a (large) superset of the Range concept. I am not proposing that sub_match model Container.

Thanks! Nate

comment:3 Changed 20 months ago by eric_niebler

Fixed on trunk in [80300]. I've taken the boost::iterator_range and std::pair route and kept const_iterator the same as iterator. Thanks!

comment:4 Changed 19 months ago by eric_niebler

  • Status changed from assigned to closed
  • Resolution set to fixed

Fixed on release in [80581]. Will be part of Boost 1.52.

comment:5 Changed 15 months ago by michel

begin/end member functions might be better, since they also support C++11 range-based for.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.