The third question is about a runtime error I'm getting in the above code. The comment in main shows the scenario. Basically if I use 0xffff as the end of the first range I get an ASSERT at runtime whereas 0xfffe works fine.

You can use icl interval containers with limited integral numeric domain-types safely on intervals using values from ++std::min<T>() to --std::max<T>(): Two values less. So if you want to manage a domain of values like in your example, you'd need to use a larger value type. It is possible to make the code handle those corner cases correctly (yet not trivial, since it is generic code). For achieving that the most frequently called functions would all need to make additional checks making the code ugly and more slowly. And yes, this information should be added to the documentation.
 
 
Ok this assessment was premature ... and thank you for your patch. It fixes the problem and I have already pushed the changes. For other interval types and their corner cases I will write a few tests shortly.


--
Interval Container Library [Boost.Icl]
http://www.joachim-faulhaber.de