Implement saity checks for irange and its returned type iterator_range.
The implementation does not support backwards counting ranges, but fails to assert on this condition. Fix this once and for all.
This commit is contained in:
parent
f95a4b9b46
commit
2470494009
@ -28,6 +28,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#ifndef INTEGER_RANGE_HPP
|
#ifndef INTEGER_RANGE_HPP
|
||||||
#define INTEGER_RANGE_HPP
|
#define INTEGER_RANGE_HPP
|
||||||
|
|
||||||
|
#include <boost/assert.hpp>
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
@ -42,6 +44,7 @@ template <typename Integer> class range
|
|||||||
public:
|
public:
|
||||||
range(Integer start, Integer end) noexcept : last(end), iter(start)
|
range(Integer start, Integer end) noexcept : last(end), iter(start)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT_MSG(start <= end, "backwards counting ranges not suppoted");
|
||||||
static_assert(std::is_integral<Integer>::value, "range type must be integral");
|
static_assert(std::is_integral<Integer>::value, "range type must be integral");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user