|
Boost : |
From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2002-11-21 19:41:34
----- 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;
}
It also allows you to not apply explicit casts to several parameters to
select the function you want:
#include <iostream>
int f2(int x, int y) {
return x + y;
}
double f2(double x, double y) {
return x + y;
}
int main() {
int x = ambiguity_cast<int (int, int)>(f2)(2.5, 3.5);
return 0;
}
;)
Paul Mensonides
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk