Opened 14 years ago
Closed 14 years ago
#2009 closed Feature Requests (wontfix)
suggested resiliency/ease-of-use
Reported by: | Dave Abrahams | Owned by: | Thorsten Ottosen |
---|---|---|---|
Milestone: | Boost 1.36.0 | Component: | range |
Version: | Boost 1.35.0 | Severity: | Problem |
Keywords: | Cc: | Eric Niebler |
Description
If I define a range type X and define only
X::iterator range_begin(X const&);
assuming that it should be picked up for const
or non-const X
, generic code will break when passed a non-const X
when it tries to do boost::begin(x)
and that expression reaches inside X
looking for a begin()
member.
It's possible to make the library resilient against this issue as shown by the enclosed example
Attachments (1)
Change History (6)
by , 14 years ago
comment:1 by , 14 years ago
comment:2 by , 14 years ago
The problem is what happens with range1 with today's library. I put range2 in there just to prove that my solution doesn't break the other cases.
comment:3 by , 14 years ago
Ok, I wondering if we could make it a bit simpler by only disabling begin( T& ) if the two iterator types are the same? Or do you want it to work if only one of the iterator types is defined?
-Thorsten
comment:4 by , 14 years ago
Cc: | added |
---|
Oh, well, I suppose it's preferable to work with only one of the iterator types defined as well. On the other hand, I realize this whole thing is really only an issue for a person who is adapting an existing type to the Range concept, since the rest of us can use member functions and nested typedefs, which is sufficiently economical. You might consider whether it is important enough to do anything about.
comment:5 by , 14 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
I could "fix" the code for range2 by adding one typedef:
Is that good enough, or do you still think it is a big problem that two versions of range_begin() needs to be defined?
-Thorsten