Travis Vitek wrote:
[...]
The problem is that many of the trait tests do this type of thing. I can work around this pretty easily by explicitly
instantating each template in each test, but this is tedious
(there are many).
I'm not sure I understand why you are even considering working
around it. Doesn't the bug make the built-in traits pretty much
unusable in generic code?

Not always. If the template is instantiated the error would not be seen.

The reason I ask is because I couldn't get even a simple SFINAE
test program to compile. I think the program is well-formed even
though gcc 4.3.0 chokes on too (albeit for a different reason --
see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36797)

$ cat t.cpp && eccp -A t.cpp
#include <assert.h>

template <int> struct S { };

template <class, bool> struct enable_if;
template <class T> struct enable_if<T, true> { typedef T type; };

template <class T>
int foo (typename enable_if<T,  __is_empty (T)>::type* = 0) { return 0; }

template <class T>
int foo (typename enable_if<T,  !__is_empty (T)>::type* = 0) { return 1; }

int main ()
{
    assert (0 == foo<S<0> >());
    assert (1 == foo<int>());
}
"t.cpp", line 16: error: no instance of overloaded function "foo" matches the
          argument list
      assert (0 == foo<S<0> >());
      ^

1 error detected in the compilation of "t.cpp".



Martin

I was thinking about doing something like this...

#define _INSTANTIATE(T)                                       \
  typedef typename                                            \
  __rw_conditional<__rw_is_class_or_union<T>::value,          \
                   T::type,                                   \
                   void>::type _RWSTD_PASTE(dummy, __LINE__);

And then sneaking a void typedef into each of my user
defined types, and
then using this macro in the TEST () macro that I use all over the
tests. Is there a better way?

Travis


Reply via email to