
On Fri, Aug 13, 2004 at 07:17:33PM -0700, Paul Mensonides wrote:
From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Christoph Ludwig
However, this problem is by no means specific to the serialization library.
No, it isn't.
Note also that the solution is incomplete. Types have to not only be capable of being argument types (e.g. not 'void'), but they also must remain unchanged by simply being an argument type (e.g. array declarations decay to pointers, function types are transformed to pointer to function types). In other words, the solution only works for the common case.
Just for clarification: You say that in the following template<class> struct pack; template<class T> struct<void (T)> { typedef T type; }; MY_MACRO(pack<void (void)>::type) MY_MACRO(pack<void (MyTemplate<int, int>[10])>::type) both macro expansions won't work (or more precisely, result in code that will fail or yield unwanted results when compiled)? Hm, I probably should peruse my copy of the book by Vandvoorde and Josuttis again, but this makes kind of sense. IIUC this might be a problem if you need to be able to pass *any* type to a macro. But in the case of the serialization lib it's always a class type that needs to be registered. And neither void nor MyTemplate<int, int>[10] is a class type. Are you aware of any examples where above approach won't work when calling the serialization lib's export macros?
Whenever you have a macro that takes a classname you may face this issue. One could consider it a (inherent) preprocessor shortcoming solved by means of template programming.
As an aside, if you have a conforming preprocessor, the problem is solveable with the preprocessor (especially so with variadics).
Is it solveable with the preprocessor as defined in the C++ standard from 1998? Or do you need the C99 preprocessor? Regards Christoph -- http://www.informatik.tu-darmstadt.de/TI/Mitarbeiter/cludwig.html LiDIA: http://www.informatik.tu-darmstadt.de/TI/LiDIA/Welcome.html