Boost logo

Boost :

From: Moore, Paul (Paul.Moore_at_[hidden])
Date: 1999-12-06 08:16:49

From: Kevlin Henney [mailto:Kevlin.Henney_at_[hidden]]
> In the absence of explicit UDC operators, the suggestion here is to
> introduce a rational_cast template. It has a default implementation
> (following the existing as_* implementations) and can be further
> specialised as necessary:

Yes, I like it. At one stage I had a member template as<type> which did the
same sort of thing - but I like your name better.

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


    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")?


Boost list run by bdawes at, gregod at, cpdaniel at, john at