Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2000-10-26 13:16:05


----- Original Message -----
From: "William Kempf" <sirwillard_at_[hidden]>

> Just to let everyone know what I've found lately while attempting to
> use the "hacks" discussed here to get a tuple on VC6.
>
> Though the recent "hacks" at first appear promising (and in fact they
> may help with limited problem domains) they aren't going to do us
> much good as a general work around. VC6 has more troubles than just
> poor conformance with the standard with regards to no partial
> template specialization. It's also riddled with parsing and
> generation bugs. The simplest illustration I can give for a dreadful
> parsing bug can be reduced down to the following example program:
>
> #include <boost\call_traits.hpp>
>
> template <typename T1, typename T2>
> void test(boost::call_traits<T1>::param_type p1,
> boost::call_traits<T2>::param_type p2)
> {
> p1 = p2; // Just something stupid to insure full parsing.
> }
>
> int main()
> {
> test(10, 'c');
> return 0;
> }

I am by no means an expert in this area of the standard, but the usage above
looks really suspicious to me, all VC issues aside. Consider what we're
asking the compiler to do: It must deduce a unique T1 for which the
specialization of call_traits has a nested type param_type which matches the
argument to test(). Can we really use param_type this way (with a deduced
function template argument)? At best this seems fragile, since not all
specializations of call_traits may be visible. At worst, it seems like it
could lead to the kind of errors you're seeing. I think this is probably a
compiler bug, since in general template arguments must match exactly, but
I'm not certain this isn't an edge case. Certainly, both 10 and 'c' are
implicitly convertible to boost::call_traits<int>::param_type and
boost::call_traits<char>::param_type.

-Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk