|
Boost : |
From: Eric Niebler (eric_at_[hidden])
Date: 2005-05-21 11:15:31
Arkadiy Vertleyb wrote:
> Here is the minimal example:
>
> // ----
> #include "boost/mpl/vector.hpp"
> #include "boost/mpl/size_t.hpp"
>
> template<class T> T make();
>
> template<class T>
> struct et
> {
> typedef boost::mpl::vector1<int> type;
> };
>
> template<class T>
> char(&sz(const T&))[
> boost::mpl::size<
> typename et<T>::type
> >::value
> ];
>
> template<class T, class U>
> struct add
> {
> typedef boost::mpl::vector1<
> boost::mpl::size_t<sizeof(sz(make<T>() + make<U>()))>
> //boost::mpl::size_t<sizeof(sz(T() + U()))> -- doesn't help here
> > type;
> };
>
> int main()
> {
> return 0;
> }
> // ----
>
> This example compiles fine with GCC, but both MS compilers choke on it.
I have experienced this problem before, and the fix is to calculate the
return type of the sz() function as a separate step:
#include "boost/mpl/vector.hpp"
#include "boost/mpl/size_t.hpp"
template<class T> T make();
template<class T>
struct et
{
typedef boost::mpl::vector1<int> type;
};
template<class T>
struct sizer
{
typedef char(&type)[
boost::mpl::size<
typename et<T>::type
>::value
];
};
template<class T>
typename sizer<T>::type sz(const T&);
template<class T, class U>
struct add
{
typedef boost::mpl::vector1<
boost::mpl::size_t<sizeof(sz(make<T>() + make<U>()))>
> type;
};
This compiles with VC7.1 and with gcc. I don't have VC8 beta installed.
>
> Do Microsoft people read this list, or should I post it elsewhere?
>
Report the bug at the product feedback center:
http://lab.msdn.microsoft.com/productfeedback/
-- Eric Niebler Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk