I am currently designing an API where I want that the user to be able to write code like this:
PowerMeter.forceVoltage(1 mV);
PowerMeter.settlingTime(1 ms);
Take a look at Boost.Units. Here's some example code:
quantity
work(const quantity& F, const quantity& dx)
{
return F * dx; // Defines the relation: work = force * distance.
}
...
/// Test calculation of work.
quantity F(2.0 * newton); // Define a quantity of force.
quantity dx(2.0 * meter); // and a distance,
quantity E(work(F,dx)); // and calculate the work done.