I'm using Boost.Range to pass around some data and a container class for this data. The data is loaded in a different thread and may in some cases not be ready yet. In this case the container is initialized with the default iterator_range, hence containing singular iterators. I'm doing assignments and copying of the data containers (hence the iterator_ranges). However, the iterator_range copy constructor calls begin() and end() which will assert when the original is singular. Therefor, it is not possible to copy an empty data container.
Is there any way to avoid this limitation?
Why is this limitation been implemented? The following works just fine, shouldn't ranges behave similarly?
typedef std::vector<int>::iterator iterator;
iterator it; // Singular
iterator it2 = it; // Works
boost::iterator_range<iterator> range; // Singular
boost::iterator_range<iterator> range2 = range; // Asserts in debug, but why?