#7237 closed Feature Requests (fixed)
Make sub_match a proper range
Reported by: | 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>.
Change History (5)
comment:1 by , 10 years ago
Status: | new → assigned |
---|
comment:2 by , 10 years ago
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 by , 10 years ago
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 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fixed on release in [80581]. Will be part of Boost 1.52.
comment:5 by , 10 years ago
begin/end member functions might be better, since they also support C++11 range-based for.
xpressive's
sub_match
is closely modeled onstd::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 makesub_match
a valid range by hooking Boost.Range's customization points.But would
sub_match
'sconst_iterator
be a typedef foriterator
, or would it const-ify the iterator (if necessary)? And do I needrbegin
/rend
,cbegin
/cend
,crbegin
/crend
and the associated typedefs, too? Sheesh! Opinions?