
Hi,
I took much labour in defining an extra system of units (atomic
units). It works very well and it also defines (optionaly) default
conversion from atomic to SI units. The problem that I have now is
that all the conversion has to be done explicitly. I understand that
this way of doing thing is by design.
But for some formulas I would like to allow implicit conversion, for
example when adding energies in SI and energies in atomic units (I
don't care which direction the conversion is done since I will
transform to one of the two at the end of the formula). On top of that
the Units Manual says:
"Safety and the potential for unintended conversions leading to
precision loss and hidden performance costs. Options are provided for
forcing implicit conversions between specific units to be allowed. "
The question is which are the "Options provided for forcing implicit
conversion"?
What follow is an example:
What I want is some controlled implicit conversion (even better is
this conversion are allowed inside a certain program scope). Note that
line 4 doesn't work:
quantitysi::energy e1(3.*si::joules);
quantityatomic::energy e2(4.*atomic::hartree);
quantityatomic::energy e3(e1); //works
e1 = e2; //doesn't work
e1 = quantitysi::energy(e2); //works
cout<