
"Daniel Frey" <daniel.frey@aixigo.de> wrote
The reason is, that the author of the constant library (or the constants) cannot know which unit-libraries are to be supported, and the author of the unit-library doesn't want to register stuff for a specific constant library. Dependencies. The problem is, that you have to register operators for pairs of arguments, one from the unit library, the other from the constant-library. Who is supposed to do that?
Perhaps I could take a closer look at this (if you help me, of course) at some point, but in short, the author of constant library registers constants, and the author of unit library registers units, and whoever writes operators registers them with no respect to units or constants. How this all gets resolved in terms of IDs is another story. If we assign IDs automatically, the only problem we have is a possible ODR violation. If we don't want this, the libraries may register against undefined symbolic constants, and the end-user could resolve this in a system-wide enum. This is feasible because an ID is assigned on per-file basis, not per-class. Inside the file I distinguish by __LINE__. So there most likely would be one constant per library, and the end-user would do something like this: --- MyGroups.hpp: enum { UNIT_LIBRARY_GROUP = BOOST_TYPEOF_USER_GROUP, CONSTANT_LIBRARY_GROUP, OPERATOR_GROUP }; --- #include "MyGroups.hpp" #include <boost/unit_registration.hpp> #include <boost/constant_registration.hpp> #include <boost/operator_registration.hpp> // use BOOST_TYPEOF and BOOST_AUTO Arkadiy