type traits, reflection, and whatnot

Phil Edwards phil@jaj.com
Tue Jan 14 07:54:00 GMT 2003


On Mon, Jan 13, 2003 at 05:36:18AM +0100, Gabriel Dos Reis wrote:
> Phil Edwards <phil@jaj.com> writes:
> | 
> | It's annoying and repetitive.
> 
> So, now the issue isn't that it is difficult, but that _you_ find it
> annoying and repetitive.  Well, ...

Yes, and I find annoying and repetitive things to be difficult to maintain.
Bored programmers make mistakes.  Same issue.  :-)

Anyhow, I think this has become moot (see next message).


> | > On the other hand hardwiring things in pt.c means one has to
> | > check many places for special templates.  Many checks means equally
> | > opportunities to miss bits.
> | 
> | No, only one place.  There's a single change in pt.c, a single 'if'.
> 
> Not really.  If you at it well, then you'll notice that it is more
> than just one place.

Sorry, I didn't make myself clear.  I'm not talking about a /theoretical/
change.  It's done, it's working, and I only had to change a single 'if'
to do it:

[mail continues after patch]


Index: pt.c
===================================================================
RCS file: /home/pme/Repositories/GCC/gcc/gcc/cp/pt.c,v
retrieving revision 1.647
diff -u -3 -p -r1.647 pt.c
--- pt.c	10 Jan 2003 02:22:18 -0000	1.647
+++ pt.c	14 Jan 2003 07:48:23 -0000
@@ -42,6 +42,7 @@ Boston, MA 02111-1307, USA.  */
 #include "toplev.h"
 #include "rtl.h"
 #include "timevar.h"
+#include "traits.h"
 
 /* The type of functions taking a tree, and some additional data, and
    returning an int.  */
@@ -5219,7 +5220,16 @@ instantiate_class_template (type)
   /* If the template we're instantiating is incomplete, then clearly
      there's nothing we can do.  */
   if (!COMPLETE_TYPE_P (pattern))
-    return type;
+    {
+      /* Unless it's one of the special types for which we do this.  */
+      if (traits_active_p && is_traits_class_p (pattern))
+        {
+          type = complete_traits_for (pattern, args, type);
+          TYPE_SIZE (type) = bitsize_zero_node;
+          return instantiate_class_template (type);
+        }
+      else return type;
+    }
 
   /* If this is a partial instantiation, don't tsubst anything.  We will
      only use this type for implicit typename, so the actual contents don't


That 'if' in instantiate_class_template usually isn't taken, I believe;
I wanted to stay off the critical code path.

Anyhow, like I said, moot issue.


Phil



More information about the Libstdc++ mailing list