* verify.h (verify_true): Provide alternative definition for C++.
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 5 Oct 2005 06:50:03 +0000 (06:50 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 5 Oct 2005 06:50:03 +0000 (06:50 +0000)
lib/ChangeLog
lib/verify.h

index 190c237d7f23fb00f2a8e325b34311ac6f4fcdd1..c490d5bf46749738afe6a21e6aba6ef81e4bd694 100644 (file)
@@ -1,3 +1,7 @@
+2005-10-04  Bruno Haible  <bruno@clisp.org>
+
+       * verify.h (verify_true): Provide alternative definition for C++.
+
 2005-10-04  Simon Josefsson  <jas@extundo.com>
 
        * getaddrinfo.h: Move sys/types.h include first, reported by "Mark
index d782e73b2421a766fd262af637149c99642e2bc0..328980fa362917971489b059236f60349bd09c3f 100644 (file)
 /* Verify requirement R at compile-time, as an integer constant expression.
    Return true.  */
 
-# define verify_true(R) \
-    (!!sizeof \
-     (struct { unsigned int verify_error_if_negative_size__ : (R) ? 1 : -1; }))
+# ifdef __cplusplus
+template <int w>
+  struct verify_type__ { unsigned int verify_error_if_negative_size__: w; };
+#  define verify_true(R) \
+     (!!sizeof (verify_type__<(R) ? 1 : -1>))
+# else
+#  define verify_true(R) \
+     (!!sizeof \
+      (struct { unsigned int verify_error_if_negative_size__: (R) ? 1 : -1; }))
+# endif
 
 /* Verify requirement R at compile-time, as a declaration without a
    trailing ';'.  */