|
Boost : |
From: Ed Brey (brey_at_[hidden])
Date: 1999-12-06 09:44:12
"Moore, Paul" wrote:
>
> One annoyance (and the reason I ditched the as<> approach) is that MS Visual
> C++ doesn't like the construct much. (OK, so nobody is surprised - but sadly
> I use MSVC). The issue is that
>
> using boost::rational_cast;
> cout << rational_cast<float>(r);
>
> complains about
>
> rational_test.cpp(25) : error C2679: binary '<<' : no operator defined which
> takes a right-hand operand of type '' (or there is no acceptable conversion)
> rational_test.cpp(25) : error C2062: type 'float' unexpected
>
> whereas
>
> cout << boost::rational_cast<float>(r);
>
> works fine.
>
> Does anyone know any magic incantations which would persuade MSVC to accept
> this (excluding the obvious one of "go to another compiler vendor")?
This is a case where it is ligitimate to (hopefully temporarily)
employ the evils of a macro to make up for the evils of Microsoft.
#include <boost/rational.hpp>
#if !defined(_MSC_VER) || _MSC_VER > 1200 || defined(__ICL)
using boost::rational_cast;
#else
#define rational_cast boost::rational_cast
#endif
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk