
#include <string>
#include <iostream>
class foo {
};

class bar {
    public:
        const foo & to_foo() const {
            return f;
        }

        foo & to_foo() {
            return f;
        }
    private:
        foo f;
};

template< typename T, typename Enable = void>
class convert {};

template< typename T>
struct convert<T>{
    static const foo & call1( const bar & b ) {
        std::cout<<"call1"<<std::endl;
        return b.to_foo();
    }

    static foo & call2( bar & b ) {
        std::cout<<"call2"<<std::endl;
        return b.to_foo();
    }
};
int main()
{
    bar b;
    const bar cb = b;
    convert<std::string> converter;
    converter.call1(cb);
    converter.call2(b);

    return 0;
}
  