Re: Constraints => Traits
IR wrote:
IR wrote:
Sorry for the double post, I just wanted to let people know a
certain mainstream compiler (*cough* VC8 *cough*) chokes on this
specialization
template< class T>
struct has_copy_member<T,
typename if_<sizeof( MFTest<T>::f(&T::copy) )
== sizeof(Bool<true>),
T, void >::type >
{ static const bool value = true; };
it can't resolve MFTest<T>::f(&T::copy)
=> C2064: term does not evaluate to a function taking 1 arguments
although it can correctly evaluate
sizeof(MFTest<A>::f(&A::copy))
My tests seem to show it is really a compiler-specific error, so
I'm forwarding that problem to microsoft.public.vc.language and I
will let this group know if a workaround is found.
In microsoft.public.vc.language, Igor Tandetnik wrote:
14.5.4/9 A partially specialized non-type argument expression
shall not involve a template parameter of the partial
specialization except when the argument expression is a simple
identifier.
It's a complete reasonable explanation for a completely irrelevant
problem. The expression in the original program that gives the
Microsoft compiler trouble: "MFTest<T>::f(&T::copy)" is not a partial
specialization, so a partial template specialization error cannot be
the explanation why it should fail to compile.
As a side note, Comeau Online didn't even blink on Greg Herlihy's
original code (that's why I though the problem was VC8-specific).
You were correct, the problem is VC8-specific.
But the simplified code I posted in microsoft.public.vc.language
does trigger the error correctly:
Your example has not "simplified" the original code. Instead it simply
replaces the original (correct) code with a set of completely different
(and incorrect) code that does not even cause the same error message to
appear as the original.
template<class T> struct A { static int f(); };
template<class, size_t> struct B;
template<class T>
struct B<T,
sizeof(A<T>::f()) //C2064
>
{};
"error: the template argument list of the partial specialization
includes a nontype argument whose type depends on a template
parameter"
First, a type parameter dependency error is not even possible in the
original class template, because the MFTest class template accepts only
one type parameter:
sizeof( MFTest<T>::f(&T::copy));
I'm not sure why Comeau didn't detect the error in Greg's code, but
I guess this has to do with deferred template instanciation, or
something like that...
Diagnosing a compiler error requires diagnosing the actual code that
reproduces the failure - not to diagnose a different set of unrelated
code - which while perhaps less compilicated than the original code -
is code that nonethelss legitimately fails to compile.
To Greg Herlihy: for the sake of curiosity, which compiler did you
use?
I used a C++ compiler. Perhaps I should have mentioned that a C++
compiler is required to compile the original program as posted.
Greg
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]