Template Metaprogramming I/O (well, O anyway)

I asked this question a year or two ago on the list. Has anyone come up with a good way to dump template metaprogramming information at compile time? I'd like to be able to do this both in a "print" sense (compiler warnings) and an "error" sence (compiler abort). I hacked something together last week that sort of does the job. There's a print<Message, FileLine> class that has a constructor with an unused variable declared. gcc gives a nice warning with -Wall. I also have some hacked macros to pass file and line number information to the printer. The printer will dump a warning if its constructor is ever instantiated. The use of all this appears in my last post in the "Named Template Parameters" thread. But this is really terrible. I don't like it much so I'm hoping someone else has a better solution. In particular, it's almost useless if there are any errors in the code because compilation will stop before instantiation happens. Unfortunately, this is _exactly_ the case where one really wants to get this information and figure out what's causing the compiler abort. I know this is useful functionality, practically required for any large metaprogramming project. I'd like to see if Boost can make something really good. -Dave

David Greene wrote:
I asked this question a year or two ago on the list.
Has anyone come up with a good way to dump template metaprogramming information at compile time? I'd like to be able to do this both in a "print" sense (compiler warnings) and an "error" sence (compiler abort).
I think <boost/mpl/print.hpp> is supposed to do this, although I'm not sure how well it works over a wide range of compilers.
I hacked something together last week that sort of does the job. There's a print<Message, FileLine> class that has a constructor with an unused variable declared. gcc gives a nice warning with -Wall. I also have some hacked macros to pass file and line number information to the printer.
I think you'll find that different compilers give very different results. I suggest you try it on three or four compilers, at least. Jonathan

Jonathan Turkanis wrote:
David Greene wrote:
I asked this question a year or two ago on the list.
Has anyone come up with a good way to dump template metaprogramming information at compile time? I'd like to be able to do this both in a "print" sense (compiler warnings) and an "error" sence (compiler abort).
I think <boost/mpl/print.hpp> is supposed to do this, although I'm not sure how well it works over a wide range of compilers.
I hacked something together last week that sort of does the job. There's a print<Message, FileLine> class that has a constructor with an unused variable declared. gcc gives a nice warning with -Wall. I also have some hacked macros to pass file and line number information to the printer.
I think you'll find that different compilers give very different results. I suggest you try it on three or four compilers, at least.
David, if you find that your print template works on some compilers or in some configurations where the MPL one doesn't, I'd be very eager to fold your technology for those compilers into the MPL version. Thanks, -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

David Abrahams wrote:
David, if you find that your print template works on some compilers or in some configurations where the MPL one doesn't, I'd be very eager to fold your technology for those compilers into the MPL version.
I doubt it will work on things that mpl::print doesn't. MPL's print doesn't seem to be documented in the reference manual. Is this an oversight? Wish I'd known about it earlier. :) -Dave

David Greene wrote:
David Abrahams wrote:
David, if you find that your print template works on some compilers or in some configurations where the MPL one doesn't, I'd be very eager to fold your technology for those compilers into the MPL version.
I doubt it will work on things that mpl::print doesn't.
MPL's print doesn't seem to be documented in the reference manual. Is this an oversight?
Probably.
Wish I'd known about it earlier. :)
It's covered in http://www.boost-consulting.com/metaprogramming-book, FWIW. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

David Abrahams wrote:
It's covered in http://www.boost-consulting.com/metaprogramming-book, FWIW.
Yep, I was already planning to buy it when it becomes available. When is that, anyway? -Dave

David Greene wrote:
David Abrahams wrote:
It's covered in http://www.boost-consulting.com/metaprogramming-book, FWIW.
Yep, I was already planning to buy it when it becomes available.
When is that, anyway?
About 2 weeks ago. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com
participants (3)
-
David Abrahams
-
David Greene
-
Jonathan Turkanis