2

I'm typing the following in my code

boost::numeric::interval<double> foo = ...;
double length = std::abs(foo.upper() - foo.lower());

It surprises me I can't find a simple utility in boost::numeric::interval that calculates the length. I'd expect a length function so that I can do

boost::numeric::interval<double> foo = ...;
double length = length(foo);

Is this either

  • missing from the library as an oversight
  • missing from the library for good reason as it doesn't fit the concept
  • there but under another name which I've failed to see

Obviously I can write a simple inline function to do this but I'm a bit surprised that I have to given that I see functions like min and max

bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217

1 Answers1

3

I just found it after I posted the question

Answer is "width"

boost::numeric::interval<double> foo = ...;
double length = width(foo);
bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217