
On 07/03/2011 02:21 PM, Edward Diener wrote:
This seems a serious deficiency. I feel it would be better to generate these macro metafunctions in a namespace specific to the code that wants to use them, rather than putting them all in boost::tti. That would essentially eliminate the risk of cross-library ODR violations. What is your motivation for putting all the macro metafunctions in the same namespace?
You have made a very good point.
My intention, evidently misguided, was to put the generated metafunctions in the boost::tti namespace to avoid polluting the global namespace. But I see now that I should not have added a namespace at all and the end-user could then use the macros in whatever namespace he wants in order to avoid ODR violations, and/or just use the complicated macro form to create a unique name for the metafunction. Actually, of course, that still could be done, but a full metafuncion name of 'anamespace::boost::tti::has_type_mytype' is more gruesome than 'anamespace::has_type_mytype'.
Thanks for pointing this out.
How about checking with the preprocessor if the meta-function has already been defined, and not defining it in that case?