|
Boost : |
From: John Maddock (John_Maddock_at_[hidden])
Date: 2001-08-26 06:21:52
>I experimented a bit with tuple.hpp to see what's wrong; here's a minimal
>example I've found that fails on both VC 6 and VC 7:
>
>#include <boost/type_traits.hpp>
>
>template<int N> boost::add_reference<int>::type get();
This is so weird, I've experimented a bit with this and the following
program fails with an internal compiler error on vc6:
template <int N> struct dummy_arg{};
template <class T>
struct dummy_traits
{
typedef T type;
};
template<int N, class T>
typename dummy_traits<T>::type get_n(T* p, const dummy_arg<N>* up = 0)
{
return p[N];
}
Note that the template is never used: it's the declaration itself that's
enough to trigger the error.
BTW the dummy_arg is used here because otherwise
get_n<1,int> and
get_n<2,int> and
get_n<3,int> etc
all have the same mangled name with vc6 - and that really screws up things
at run time. The macro to check for this is
BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS BTW.
However the above program does compile with vc7b2, in fact vc7 seems to be
doing quite well here - here's the full test program that I managed to get
working with vc7b2:
#include <boost/type_traits/transform_traits.hpp>
#include <cassert>
template <int N> struct dummy_arg{};
template <class T>
struct dummy_traits
{
typedef T type;
};
template<int N, class T>
typename dummy_traits<T>::type get_n(T* p, const dummy_arg<N>* up = 0)
{
return p[N];
}
template<int N, class T>
typename ::boost::add_reference<T>::type get_n2(T* p)
{
return p[N];
}
int main()
{
int i[3];
int ii = get_n<2>(i);
int& ir = get_n2<2>(i);
assert(&ir == &(i[2]));
double da[3];
double& d = get_n2<1>(da);
assert(&d == &(da[1]));
}
Unfortunately this doesn't help the tuple code any: that still fails with
vc7b2.
Confused again :-(
- John Maddock
http://ourworld.compuserve.com/homepages/john_maddock/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk