Boost logo

Boost Users :

Subject: [Boost-users] Distance/size of boost ranges for std::set.
From: Matthew Gwynne (mathew.gwynne_at_[hidden])
Date: 2010-10-11 05:32:35


Hi,

I'm working within a C++ library which makes extensive use of the
range concept, and also of boost::size. The current version of the
library makes use of boost 1_38, however, updating to the newer
versions of boost, I've had to replace boost::size with
boost::distance as some of the ranges involved, such as std::set don't
have random access iterators.

However, this presents a problem - it's not really acceptable within
our application to have linear time complexity for the size operation
on sets when the size member function of the set container is constant
time, so I'm looking for some advice.

Are we misusing the range concept here and should be using something
else? Everything other than this matches up nicely, and it's only the
time complexity with regards to boost::distance that will cause
problems.

Should we simply be extending the boost::size function with additional
overloaded versions specific to std::set if we wish to use it in this
way (is this reasonable?)?

Thanks in advance!

Matthew Gwynne


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