| View previous topic :: View next topic |
| Author |
Message |
morpheusStein@hotmail.com Guest
|
Posted: Fri Apr 23, 2004 12:19 am Post subject: printing template arguments |
|
|
I want to study the mechanism of expression
templates. I find that it's difficult to understand
what the template arguments are.
Is there any way to get information about the
template arguments during instantiation? Any
compiler option in g++ for such a purpose?
Thanks for your help. :-)
Moria
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
David Abrahams Guest
|
Posted: Fri Apr 23, 2004 11:08 pm Post subject: Re: printing template arguments |
|
|
[email]morpheusStein (AT) hotmail (DOT) com[/email] (morpheusStein (AT) hotmail (DOT) com) writes:
| Quote: | I want to study the mechanism of expression
templates. I find that it's difficult to understand
what the template arguments are.
Is there any way to get information about the
template arguments during instantiation? Any
compiler option in g++ for such a purpose?
Thanks for your help. :-)
Moria
|
You could instantiate boost::mpl::print<T> from within your template
(see [url]http://www.boost.org/boost/mpl/print.hpp)[/url]. It's been tuned to
generate warnings that will show you what T is on many compilers. G++
is a good one for looking at template diagnostics, because it doesn't
do overzealous "typedef substitution" like many others do, thereby
obscuring the actual types.
Cheers,
--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Pete Becker Guest
|
Posted: Sat Apr 24, 2004 11:19 am Post subject: Re: printing template arguments |
|
|
"morpheusStein (AT) hotmail (DOT) com" wrote:
| Quote: |
I want to study the mechanism of expression
templates. I find that it's difficult to understand
what the template arguments are.
Is there any way to get information about the
template arguments during instantiation? Any
compiler option in g++ for such a purpose?
|
Put an error in your code, and read the error messages. <g> Or implement
the compile-time deubgger that I invented ten years ago: it lets you
step through template instantiations as the compiler evaluates them.
--
Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Stephen C. Dewhurst Guest
|
Posted: Sun Apr 25, 2004 1:42 am Post subject: Re: printing template arguments |
|
|
On 24 Apr 2004 07:19:47 -0400, Pete Becker <petebecker (AT) acm (DOT) org> wrote:
Or implement
| Quote: | the compile-time deubgger that I invented ten years ago: it lets you
step through template instantiations as the compiler evaluates them.
|
I don't recall this. Do you have a pointer to it?
Thanks,
Steve
www.semantics.org
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Pete Becker Guest
|
Posted: Sun Apr 25, 2004 11:04 pm Post subject: Re: printing template arguments |
|
|
"Stephen C. Dewhurst" wrote:
| Quote: |
On 24 Apr 2004 07:19:47 -0400, Pete Becker <petebecker (AT) acm (DOT) org> wrote:
Or implement
the compile-time deubgger that I invented ten years ago: it lets you
step through template instantiations as the compiler evaluates them.
I don't recall this. Do you have a pointer to it?
|
www.fantasyware.com. <g>
--
Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Stephen C. Dewhurst Guest
|
Posted: Tue Apr 27, 2004 6:11 pm Post subject: Re: printing template arguments |
|
|
On 25 Apr 2004 19:04:30 -0400, Pete Becker <petebecker (AT) acm (DOT) org> wrote:
| Quote: | "Stephen C. Dewhurst" wrote:
On 24 Apr 2004 07:19:47 -0400, Pete Becker <petebecker (AT) acm (DOT) org> wrote:
Or implement
the compile-time deubgger that I invented ten years ago: it lets you
step through template instantiations as the compiler evaluates them.
I don't recall this. Do you have a pointer to it?
www.fantasyware.com.
|
Well, I guess it was too good to be true; guess I'll just keep working
on it...but thanks for the pointer anyway!
Steve
www.semantics.org
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Ben Hutchings Guest
|
Posted: Wed Apr 28, 2004 9:33 am Post subject: Re: printing template arguments |
|
|
Pete Becker wrote:
| Quote: | "Stephen C. Dewhurst" wrote:
On 24 Apr 2004 07:19:47 -0400, Pete Becker <petebecker (AT) acm (DOT) org> wrote:
Or implement
the compile-time deubgger that I invented ten years ago: it lets you
step through template instantiations as the compiler evaluates them.
I don't recall this. Do you have a pointer to it?
www.fantasyware.com.
|
It looks like it would not be too hard to add this to GNU C++ by
instrumenting functions such as instantiate_class_template,
instantiate_template and resolve_overloaded_unification in
gcc/cp/pt.c.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|