|
Boost Users : |
Subject: [Boost-users] Boost range changes [1.37.0]
From: Tomas Puverle (Tomas.Puverle_at_[hidden])
Date: 2008-11-19 16:50:30
I just upgraded from Boost 1.33.1 to 1.37.0 and have found a breaking change in
Boost.Range.
Previously, iterator_range::empty() would do the following:
bool empty() const
{
if( singular )
return true;
return m_Begin == m_End;
}
and similarly for size(). In the new release, instead of the test, there is an
assertion, which is now breaking my code.
Why (and when?) was this change introduced? This make Boost Range much in
generic code, such as
template<class Range>
void foo(const Range & r_)
{
if (r_.empty()) {...}
}
The code is frequently called with containers and ranges and works beautifully.
However, a common pattern is to call the function with a default constructed
(empty range). This now crashes. The only way to test for validity AFAICS is
to call is_singular(), unfortunately, this breaks when the function is called
with containers.
This, IMHO, was an unfortunate decision. Any suggestions anyone?
Thanks,
Tom
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net