#include #include "prelude.h" using namespace fcpp; using std::cout; using std::endl; // A <-- B X <-- Y struct A { virtual void f() const =0; }; struct B : public A { void f() const { cout << "B::f()" << endl; } }; struct X { virtual void g() const =0; }; struct Y : public X { void g() const { cout << "Y::g()" << endl; } }; struct fun_from_A_to_Y : public CFunType,Ref > { Ref operator()( Ref ) const { return Ref(new Y); } }; Y* foo( A*, A*, A* ) { return 0; } int main() { Fun1,Ref > fay = makeFun1( fun_from_A_to_Y() ); Fun1,Ref > fbx = fay; // woohoo! fbx( Ref(new B) )->g(); Ref rb; Ref rcb = rb; //Ref rv = rb; // unsafe if( rcb == rb ) cout << "yay" << endl; //rb = rcb; //Fun1 oops = fbx; //Fun1 oops = explicit_convert1(fbx); //Fun1 crap = fbx; Fun3 faaay = ptr_to_fun(&foo); Fun3 fbbbx = faaay; B* bn = 0; X* xxx = fbbbx(bn)(bn)(bn); if( !xxx ) cout << "yay" << endl; }