Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-11-29 13:52:38


"Paul Mensonides" <pmenso57_at_[hidden]> writes:

> ----- Original Message -----
> From: "David Abrahams" <dave_at_[hidden]>
>
>> Thoughts?
>
> We also need this:
>
> template<class func> inline func& ambiguity_cast(func& rf) {
> return rf;
> }
>
> ...which casts away ambiguity of a function call--even by return type.
> Maybe add a static assertion to enforce function types.
>
> #include <iostream>
>
> namespace A {
> int f() {
> std::cout << "int A::f()" << &std::endl;
> return 0;
> }
> }
>
> namespace B {
> double f() {
> std::cout << "double B::f()" << &std::endl;
> return 0.0;
> }
> }
>
> using A::f;
> using B::f;
>
> int main() {
> ambiguity_cast<double ()>(f)();
> return 0;
> }

How is this different from

    implicit_cast<double(&)()>(f)()

??

-- 
                       David Abrahams
   dave_at_[hidden] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

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